From d284bb069fb4e76058feaecc5f184e6ad2383bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:22:23 +0300 Subject: [PATCH 001/106] Added empty Volo.Abp.Dapr package --- common.DotSettings | 1 + framework/Volo.Abp.sln | 7 +++++ framework/src/Volo.Abp.Dapr/AbpDaprModule.cs | 8 +++++ framework/src/Volo.Abp.Dapr/FodyWeavers.xml | 3 ++ framework/src/Volo.Abp.Dapr/FodyWeavers.xsd | 30 +++++++++++++++++++ .../src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj | 20 +++++++++++++ nupkg/common.ps1 | 1 + 7 files changed, 70 insertions(+) create mode 100644 framework/src/Volo.Abp.Dapr/AbpDaprModule.cs create mode 100644 framework/src/Volo.Abp.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj diff --git a/common.DotSettings b/common.DotSettings index 5c1cda48fd..f2cc0339ae 100644 --- a/common.DotSettings +++ b/common.DotSettings @@ -38,5 +38,6 @@ False False False + True True \ No newline at end of file diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index fadd40bcc5..f86448ee20 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -409,6 +409,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.RemoteServices", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.PlugIn", "test\Volo.Abp.AspNetCore.Mvc.PlugIn\Volo.Abp.AspNetCore.Mvc.PlugIn.csproj", "{C6D6D878-208A-4FD2-822E-365545D8681B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Dapr", "src\Volo.Abp.Dapr\Volo.Abp.Dapr.csproj", "{192A829F-D608-4E41-8DE0-058E943E453F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1219,6 +1221,10 @@ Global {C6D6D878-208A-4FD2-822E-365545D8681B}.Debug|Any CPU.Build.0 = Debug|Any CPU {C6D6D878-208A-4FD2-822E-365545D8681B}.Release|Any CPU.ActiveCfg = Release|Any CPU {C6D6D878-208A-4FD2-822E-365545D8681B}.Release|Any CPU.Build.0 = Release|Any CPU + {192A829F-D608-4E41-8DE0-058E943E453F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {192A829F-D608-4E41-8DE0-058E943E453F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1425,6 +1431,7 @@ Global {3683340D-92F5-4B14-B77B-34A163333309} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {EDFFDA74-090D-439C-A58D-06CCF86D4423} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {C6D6D878-208A-4FD2-822E-365545D8681B} = {447C8A77-E5F0-4538-8687-7383196D04EA} + {192A829F-D608-4E41-8DE0-058E943E453F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Dapr/AbpDaprModule.cs b/framework/src/Volo.Abp.Dapr/AbpDaprModule.cs new file mode 100644 index 0000000000..d69d1088f4 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/AbpDaprModule.cs @@ -0,0 +1,8 @@ +using Volo.Abp.Modularity; + +namespace Volo.Abp.Dapr; + +public class AbpDaprModule : AbpModule +{ + +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..00e1d9a1c1 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/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/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj new file mode 100644 index 0000000000..c8b3297a4a --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj @@ -0,0 +1,20 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index f13746aed0..f05b16db52 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -155,6 +155,7 @@ $projects = ( "framework/src/Volo.Abp.Core", "framework/src/Volo.Abp", "framework/src/Volo.Abp.Dapper", + "framework/src/Volo.Abp.Dapr", "framework/src/Volo.Abp.Data", "framework/src/Volo.Abp.Ddd.Application", "framework/src/Volo.Abp.Ddd.Application.Contracts", From 6f9750fa50ef224f7bc03329115b25abcf98a175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:26:17 +0300 Subject: [PATCH 002/106] Added Volo.Abp.EventBus.Dapr package. --- framework/Volo.Abp.sln | 7 +++++ framework/src/Volo.Abp.Dapr/FodyWeavers.xml | 2 +- .../AbpEventBusDaprModule.cs | 12 ++++++++ .../Volo.Abp.EventBus.Dapr/FodyWeavers.xml | 3 ++ .../Volo.Abp.EventBus.Dapr/FodyWeavers.xsd | 30 +++++++++++++++++++ .../Volo.Abp.EventBus.Dapr.csproj | 17 +++++++++++ nupkg/common.ps1 | 1 + 7 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index f86448ee20..b3516c9f6e 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -411,6 +411,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Mvc.Plu EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Dapr", "src\Volo.Abp.Dapr\Volo.Abp.Dapr.csproj", "{192A829F-D608-4E41-8DE0-058E943E453F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Dapr", "src\Volo.Abp.EventBus.Dapr\Volo.Abp.EventBus.Dapr.csproj", "{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1225,6 +1227,10 @@ Global {192A829F-D608-4E41-8DE0-058E943E453F}.Debug|Any CPU.Build.0 = Debug|Any CPU {192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.ActiveCfg = Release|Any CPU {192A829F-D608-4E41-8DE0-058E943E453F}.Release|Any CPU.Build.0 = Release|Any CPU + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1432,6 +1438,7 @@ Global {EDFFDA74-090D-439C-A58D-06CCF86D4423} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {C6D6D878-208A-4FD2-822E-365545D8681B} = {447C8A77-E5F0-4538-8687-7383196D04EA} {192A829F-D608-4E41-8DE0-058E943E453F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.Dapr/FodyWeavers.xml index 00e1d9a1c1..be0de3a908 100644 --- a/framework/src/Volo.Abp.Dapr/FodyWeavers.xml +++ b/framework/src/Volo.Abp.Dapr/FodyWeavers.xml @@ -1,3 +1,3 @@  - + \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs b/framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs new file mode 100644 index 0000000000..8d054c6bd7 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Dapr; +using Volo.Abp.Modularity; + +namespace Volo.Abp.EventBus.Dapr; + +[DependsOn( + typeof(AbpEventBusModule), + typeof(AbpDaprModule) + )] +public class AbpEventBusDaprModule : AbpModule +{ +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.EventBus.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/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/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj new file mode 100644 index 0000000000..51985afeff --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj @@ -0,0 +1,17 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index f05b16db52..ce7fb491ed 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -176,6 +176,7 @@ $projects = ( "framework/src/Volo.Abp.EventBus.Kafka", "framework/src/Volo.Abp.EventBus.Rebus", "framework/src/Volo.Abp.EventBus.Azure", + "framework/src/Volo.Abp.EventBus.Dapr", "framework/src/Volo.Abp.ExceptionHandling", "framework/src/Volo.Abp.Features", "framework/src/Volo.Abp.FluentValidation", From e8ab404420ffbd2e183d24a41e735441858b663b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:29:17 +0300 Subject: [PATCH 003/106] Added Volo.Abp.Http.Client.Dapr package. --- framework/Volo.Abp.sln | 7 +++++ .../AbpHttpClientDaprModule.cs | 12 ++++++++ .../Volo.Abp.Http.Client.Dapr/FodyWeavers.xml | 3 ++ .../Volo.Abp.Http.Client.Dapr/FodyWeavers.xsd | 30 +++++++++++++++++++ .../Volo.Abp.Http.Client.Dapr.csproj | 17 +++++++++++ nupkg/common.ps1 | 3 +- 6 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index b3516c9f6e..79b0eeabc7 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -413,6 +413,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Dapr", "src\Volo.A EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Dapr", "src\Volo.Abp.EventBus.Dapr\Volo.Abp.EventBus.Dapr.csproj", "{DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Client.Dapr", "src\Volo.Abp.Http.Client.Dapr\Volo.Abp.Http.Client.Dapr.csproj", "{18B796D2-D45D-41AE-9A42-75C9B14B20DF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1231,6 +1233,10 @@ Global {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Debug|Any CPU.Build.0 = Debug|Any CPU {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.ActiveCfg = Release|Any CPU {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431}.Release|Any CPU.Build.0 = Release|Any CPU + {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1439,6 +1445,7 @@ Global {C6D6D878-208A-4FD2-822E-365545D8681B} = {447C8A77-E5F0-4538-8687-7383196D04EA} {192A829F-D608-4E41-8DE0-058E943E453F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {18B796D2-D45D-41AE-9A42-75C9B14B20DF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs b/framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs new file mode 100644 index 0000000000..8d9a73290f --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Dapr; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Http.Client.Dapr; + +[DependsOn( + typeof(AbpHttpClientModule), + typeof(AbpDaprModule) + )] +public class AbpHttpClientDaprModule : AbpModule +{ +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.Http.Client.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/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/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj new file mode 100644 index 0000000000..a0d49df593 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj @@ -0,0 +1,17 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index ce7fb491ed..968d60b94a 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -186,7 +186,8 @@ $projects = ( "framework/src/Volo.Abp.HangFire", "framework/src/Volo.Abp.Http.Abstractions", "framework/src/Volo.Abp.Http.Client", - "framework/src/Volo.Abp.Http.Client.Web", + "framework/src/Volo.Abp.Http.Client.Dapr", + "framework/src/Volo.Abp.Http.Client.Web", "framework/src/Volo.Abp.Http.Client.IdentityModel", "framework/src/Volo.Abp.Http.Client.IdentityModel.Web", "framework/src/Volo.Abp.Http.Client.IdentityModel.WebAssembly", From f1871b8bb2d86f7bc1aeed4970523627dce577f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:38:30 +0300 Subject: [PATCH 004/106] Created empty Volo.Abp.AspNetCore.Dapr package. --- framework/Volo.Abp.sln | 7 +++++ .../AbpAspNetCoreDaprModule.cs | 13 ++++++++ .../Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml | 3 ++ .../Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd | 30 +++++++++++++++++++ .../Volo.Abp.AspNetCore.Dapr.csproj | 21 +++++++++++++ nupkg/common.ps1 | 1 + 6 files changed, 75 insertions(+) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index 79b0eeabc7..b97935b3c1 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -415,6 +415,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Dapr", "s EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Client.Dapr", "src\Volo.Abp.Http.Client.Dapr\Volo.Abp.Http.Client.Dapr.csproj", "{18B796D2-D45D-41AE-9A42-75C9B14B20DF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr", "src\Volo.Abp.AspNetCore.Dapr\Volo.Abp.AspNetCore.Dapr.csproj", "{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1237,6 +1239,10 @@ Global {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Debug|Any CPU.Build.0 = Debug|Any CPU {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.ActiveCfg = Release|Any CPU {18B796D2-D45D-41AE-9A42-75C9B14B20DF}.Release|Any CPU.Build.0 = Release|Any CPU + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1446,6 +1452,7 @@ Global {192A829F-D608-4E41-8DE0-058E943E453F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {18B796D2-D45D-41AE-9A42-75C9B14B20DF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs new file mode 100644 index 0000000000..3f84054b5e --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Dapr; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Dapr; + +[DependsOn( + typeof(AbpAspNetCoreModule), + typeof(AbpDaprModule) + )] +public class AbpAspNetCoreDaprModule : AbpModule +{ + +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.AspNetCore.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/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/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj new file mode 100644 index 0000000000..05d5de4042 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj @@ -0,0 +1,21 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + + + + + diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index 968d60b94a..c020554e5e 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -99,6 +99,7 @@ $projects = ( "framework/src/Volo.Abp.AspNetCore.Authentication.OAuth", "framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect", "framework/src/Volo.Abp.AspNetCore", + "framework/src/Volo.Abp.AspNetCore.Dapr", "framework/src/Volo.Abp.AspNetCore.Components", "framework/src/Volo.Abp.AspNetCore.Components.Server", "framework/src/Volo.Abp.AspNetCore.Components.Web", From 4be7bc3fb6926cc01a5f852bf4249fef390fcd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 19 Jul 2022 13:41:45 +0300 Subject: [PATCH 005/106] Set rootnamespaces to empty for the new dapr integration packages. --- .../src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj | 1 + .../{ => Volo/Abp/AspNetCore/Dapr}/AbpAspNetCoreDaprModule.cs | 0 framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj | 1 + framework/src/Volo.Abp.Dapr/{ => Volo/Abp/Dapr}/AbpDaprModule.cs | 0 .../src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj | 1 + .../{ => Volo/Abp/EventBus/Dapr}/AbpEventBusDaprModule.cs | 0 .../Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj | 1 + .../{ => Volo/Abp/Http/Client/Dapr}/AbpHttpClientDaprModule.cs | 0 8 files changed, 4 insertions(+) rename framework/src/Volo.Abp.AspNetCore.Dapr/{ => Volo/Abp/AspNetCore/Dapr}/AbpAspNetCoreDaprModule.cs (100%) rename framework/src/Volo.Abp.Dapr/{ => Volo/Abp/Dapr}/AbpDaprModule.cs (100%) rename framework/src/Volo.Abp.EventBus.Dapr/{ => Volo/Abp/EventBus/Dapr}/AbpEventBusDaprModule.cs (100%) rename framework/src/Volo.Abp.Http.Client.Dapr/{ => Volo/Abp/Http/Client/Dapr}/AbpHttpClientDaprModule.cs (100%) diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj index 05d5de4042..43bfc66df8 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj @@ -7,6 +7,7 @@ net6.0 enable enable + diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs similarity index 100% rename from framework/src/Volo.Abp.AspNetCore.Dapr/AbpAspNetCoreDaprModule.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs diff --git a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj index c8b3297a4a..5ba8d313e1 100644 --- a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj +++ b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj @@ -7,6 +7,7 @@ net6.0 enable enable + diff --git a/framework/src/Volo.Abp.Dapr/AbpDaprModule.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs similarity index 100% rename from framework/src/Volo.Abp.Dapr/AbpDaprModule.cs rename to framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj index 51985afeff..2bef3f9dc9 100644 --- a/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo.Abp.EventBus.Dapr.csproj @@ -7,6 +7,7 @@ net6.0 enable enable + diff --git a/framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs similarity index 100% rename from framework/src/Volo.Abp.EventBus.Dapr/AbpEventBusDaprModule.cs rename to framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj index a0d49df593..909fb156c8 100644 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo.Abp.Http.Client.Dapr.csproj @@ -7,6 +7,7 @@ net6.0 enable enable + diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs similarity index 100% rename from framework/src/Volo.Abp.Http.Client.Dapr/AbpHttpClientDaprModule.cs rename to framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs From 1fd214edec4e360a473b58ef9846d9b7eb297c9c Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Fri, 29 Jul 2022 14:34:55 +0300 Subject: [PATCH 006/106] Cli: Don't allow --preview project creation with older cli version --- .../Volo/Abp/Cli/Commands/NewCommand.cs | 5 +++-- .../Abp/Cli/Commands/ProjectCreationCommandBase.cs | 14 +++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs index 526ae77363..4f41e83643 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs @@ -31,9 +31,10 @@ public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransien ConnectionStringProvider connectionStringProvider, SolutionPackageVersionFinder solutionPackageVersionFinder, ICmdHelper cmdHelper, + CliService cliService, IInstallLibsService installLibsService, AngularPwaSupportAdder angularPwaSupportAdder) - : base(connectionStringProvider, solutionPackageVersionFinder, cmdHelper, installLibsService, angularPwaSupportAdder) + : base(connectionStringProvider, solutionPackageVersionFinder, cmdHelper, installLibsService, cliService, angularPwaSupportAdder) { TemplateProjectBuilder = templateProjectBuilder; TemplateInfoProvider = templateInfoProvider; @@ -68,7 +69,7 @@ public class NewCommand : ProjectCreationCommandBase, IConsoleCommand, ITransien Logger.LogInformation("Tiered: yes"); } - var projectArgs = GetProjectBuildArgs(commandLineArgs, template, projectName); + var projectArgs = await GetProjectBuildArgsAsync(commandLineArgs, template, projectName); var result = await TemplateProjectBuilder.BuildAsync( projectArgs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs index e672c763ae..4fdef77e8b 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProjectCreationCommandBase.cs @@ -25,6 +25,7 @@ public abstract class ProjectCreationCommandBase public SolutionPackageVersionFinder SolutionPackageVersionFinder { get; } public ICmdHelper CmdHelper { get; } public IInstallLibsService InstallLibsService { get; } + public CliService CliService { get; } public AngularPwaSupportAdder AngularPwaSupportAdder { get; } public ILogger Logger { get; set; } @@ -33,18 +34,20 @@ public abstract class ProjectCreationCommandBase SolutionPackageVersionFinder solutionPackageVersionFinder, ICmdHelper cmdHelper, IInstallLibsService installLibsService, + CliService cliService, AngularPwaSupportAdder angularPwaSupportAdder) { ConnectionStringProvider = connectionStringProvider; SolutionPackageVersionFinder = solutionPackageVersionFinder; CmdHelper = cmdHelper; InstallLibsService = installLibsService; + CliService = cliService; AngularPwaSupportAdder = angularPwaSupportAdder; Logger = NullLogger.Instance; } - protected ProjectBuildArgs GetProjectBuildArgs(CommandLineArgs commandLineArgs, string template, string projectName) + protected async Task GetProjectBuildArgsAsync(CommandLineArgs commandLineArgs, string template, string projectName) { var version = commandLineArgs.Options.GetOrNull(Options.Version.Short, Options.Version.Long); @@ -57,6 +60,15 @@ public abstract class ProjectCreationCommandBase if (preview) { Logger.LogInformation("Preview: yes"); + + var cliVersion = await CliService.GetCurrentCliVersionAsync(typeof(CliService).Assembly); + + if (!cliVersion.IsPrerelease) + { + throw new CliUsageException( + "You can only create a new preview solution with preview CLI version." + + " Update your ABP CLI to the preview version."); + } } var pwa = commandLineArgs.Options.ContainsKey(Options.ProgressiveWebApp.Short); From b9b7fbf51bf4ab5cc9985113e2417217aaf7986f Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 5 Aug 2022 11:18:40 +0800 Subject: [PATCH 007/106] Add `AbpDaprOptions`. --- .../src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs | 11 ++++++++--- .../src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs | 8 ++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs index d69d1088f4..e7f09e3c13 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs @@ -1,8 +1,13 @@ -using Volo.Abp.Modularity; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; namespace Volo.Abp.Dapr; public class AbpDaprModule : AbpModule { - -} \ No newline at end of file + public override void ConfigureServices(ServiceConfigurationContext context) + { + var configuration = context.Services.GetConfiguration(); + Configure(configuration.GetSection("Dapr")); + } +} diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs new file mode 100644 index 0000000000..e6919783af --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.Dapr; + +public class AbpDaprOptions +{ + public string HttpEndpoint { get; set; } + + public string GrpcEndpoint { get; set; } +} From d6455db2bde22e2f0bd6e60db3fdc7ceae6cc018 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 8 Aug 2022 14:03:06 +0800 Subject: [PATCH 008/106] Add `AbpDaprClientFactory`. --- .../Volo/Abp/Dapr/AbpDaprClientFactory.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs new file mode 100644 index 0000000000..2237547155 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs @@ -0,0 +1,25 @@ +using Dapr.Client; +using Microsoft.Extensions.Options; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Dapr; + +public class AbpDaprClientFactory : ITransientDependency +{ + protected AbpDaprOptions Options { get; } + + public AbpDaprClientFactory(IOptions options) + { + Options = options.Value; + } + + public virtual Task CreateAsync() + { + var daprClient = new DaprClientBuilder() + .UseHttpEndpoint(Options.HttpEndpoint) + //.UseJsonSerializationOptions()//TODO: Use abp JsonSerializerOptions + .Build(); + + return Task.FromResult(daprClient); + } +} From 000f32e6b45d5588d2a6c69b7595702710b2300f Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 8 Aug 2022 14:21:57 +0800 Subject: [PATCH 009/106] Use abp JsonSerializerOptions in `AbpDaprClientFactory`. --- .../Volo/Abp/Dapr/AbpDaprClientFactory.cs | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs index 2237547155..1cd37ceb94 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs @@ -1,25 +1,44 @@ -using Dapr.Client; +using System.Collections.Concurrent; +using System.Text.Json; +using Dapr.Client; using Microsoft.Extensions.Options; using Volo.Abp.DependencyInjection; +using Volo.Abp.Json.SystemTextJson; namespace Volo.Abp.Dapr; public class AbpDaprClientFactory : ITransientDependency { protected AbpDaprOptions Options { get; } + protected AbpSystemTextJsonSerializerOptions SystemTextJsonSerializerOptions { get; } - public AbpDaprClientFactory(IOptions options) + public AbpDaprClientFactory( + IOptions options, + IOptions systemTextJsonSerializerOptions) { Options = options.Value; + SystemTextJsonSerializerOptions = systemTextJsonSerializerOptions.Value; } - public virtual Task CreateAsync() + public virtual async Task CreateAsync() { - var daprClient = new DaprClientBuilder() + var builder = new DaprClientBuilder() .UseHttpEndpoint(Options.HttpEndpoint) - //.UseJsonSerializationOptions()//TODO: Use abp JsonSerializerOptions - .Build(); + .UseJsonSerializationOptions(await CreateJsonSerializerOptions()); - return Task.FromResult(daprClient); + if (!Options.GrpcEndpoint.IsNullOrWhiteSpace()) + { + builder.UseGrpcEndpoint(Options.GrpcEndpoint); + } + + return builder.Build(); + } + + private readonly static ConcurrentDictionary JsonSerializerOptionsCache = new ConcurrentDictionary(); + + protected virtual Task CreateJsonSerializerOptions() + { + return Task.FromResult(JsonSerializerOptionsCache.GetOrAdd(nameof(AbpDaprClientFactory), + _ => new JsonSerializerOptions(SystemTextJsonSerializerOptions.JsonSerializerOptions))); } } From 24a13f4c2934a9c3ec2fc26ed4fed96c6e653f4e Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 8 Aug 2022 14:40:46 +0800 Subject: [PATCH 010/106] Update AbpDaprModule.cs --- framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs index e7f09e3c13..43d6d11033 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprModule.cs @@ -1,8 +1,10 @@ using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Json; using Volo.Abp.Modularity; namespace Volo.Abp.Dapr; +[DependsOn(typeof(AbpJsonModule))] public class AbpDaprModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) From 54e9c6736e551d4ae091828fec1832d4de047c6d Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 8 Aug 2022 14:46:21 +0800 Subject: [PATCH 011/106] Update Volo.Abp.Dapr.csproj --- framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj index 5ba8d313e1..8c8b53ed91 100644 --- a/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj +++ b/framework/src/Volo.Abp.Dapr/Volo.Abp.Dapr.csproj @@ -12,6 +12,7 @@ + From 4a724493b99ce515178a5fa192b35cf09301c22f Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 9 Aug 2022 15:28:43 +0800 Subject: [PATCH 012/106] Implement the Dapr event bus. --- .../Volo.Abp.AspNetCore.Dapr.csproj | 8 +- .../Dapr/AbpAspNetCoreDaprConsts.cs | 8 + .../Dapr/AbpAspNetCoreDaprModule.cs | 26 ++- .../Dapr/AbpAspNetCoreDaprOptions.cs | 11 + .../AspNetCore/Dapr/AbpDaprPubSubProvider.cs | 63 +++++ ...AbpDaprPubSubProviderContributorContext.cs | 16 ++ .../Dapr/Controllers/DaprController.cs | 44 ++++ .../Dapr/IAbpDaprPubSubProviderContributor.cs | 6 + .../Dapr/Models/DaprSubscriptionDefinition.cs | 10 + .../Dapr/Models/DaprSubscriptionRequest.cs | 8 + .../AbpAspNetCoreDaprJsonNamingPolicy.cs | 11 + .../DaprSubscriptionDefinitionConverter.cs | 25 ++ .../Volo/Abp/Dapr/AbpDaprClientFactory.cs | 6 +- .../Volo/Abp/Dapr/IDaprSerializer.cs | 16 ++ .../Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs | 45 ++++ .../EventBus/Dapr/AbpDaprEventBusOptions.cs | 11 + .../EventBus/Dapr/AbpEventBusDaprModule.cs | 12 +- .../EventBus/Dapr/DaprDistributedEventBus.cs | 221 ++++++++++++++++++ 18 files changed, 539 insertions(+), 8 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs create mode 100644 framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs create mode 100644 framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpDaprEventBusOptions.cs create mode 100644 framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj index 43bfc66df8..747593eb3f 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj @@ -7,11 +7,13 @@ net6.0 enable enable - + + + @@ -19,4 +21,8 @@ + + + + diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs new file mode 100644 index 0000000000..7011d25476 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpAspNetCoreDaprConsts +{ + public const string DaprSubscribeUrl = "dapr/subscribe"; + + public const string DaprEventCallbackUrl = "api/abp/dapr/event"; +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs index 3f84054b5e..52e5820c4c 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs @@ -1,13 +1,31 @@ -using Volo.Abp.Dapr; +using Microsoft.AspNetCore.Http.Json; +using Volo.Abp.AspNetCore.Dapr.SystemTextJson; +using Volo.Abp.EventBus.Dapr; +using Volo.Abp.Json; +using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Dapr; [DependsOn( typeof(AbpAspNetCoreModule), - typeof(AbpDaprModule) + typeof(AbpEventBusDaprModule), + typeof(AbpJsonModule) )] public class AbpAspNetCoreDaprModule : AbpModule { - -} \ No newline at end of file + public override void ConfigureServices(ServiceConfigurationContext context) + { + // TODO: Add NewtonsoftJson json converter. + + Configure(options => + { + options.SerializerOptions.Converters.Add(new DaprSubscriptionDefinitionConverter()); + }); + + Configure(options => + { + options.JsonSerializerOptions.Converters.Add(new DaprSubscriptionDefinitionConverter()); + }); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs new file mode 100644 index 0000000000..17667d24b9 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpAspNetCoreDaprOptions +{ + public List Contributors { get; } + + public AbpAspNetCoreDaprOptions() + { + Contributors = new List(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs new file mode 100644 index 0000000000..27eaa294d5 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs @@ -0,0 +1,63 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.AspNetCore.Dapr.Models; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus; +using Volo.Abp.EventBus.Dapr; +using Volo.Abp.EventBus.Distributed; + +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpDaprPubSubProvider : ITransientDependency +{ + protected IServiceProvider ServiceProvider { get; } + protected AbpAspNetCoreDaprOptions Options { get; } + protected AbpDaprEventBusOptions EventBusOptions { get; } + protected AbpDistributedEventBusOptions DistributedEventBusOptions { get; } + + public AbpDaprPubSubProvider( + IServiceProvider serviceProvider, + IOptions options, + IOptions eventBusOptions, + IOptions distributedEventBusOptions) + { + ServiceProvider = serviceProvider; + EventBusOptions = eventBusOptions.Value; + Options = options.Value; + DistributedEventBusOptions = distributedEventBusOptions.Value; + } + + public virtual async Task> GetSubscriptionsAsync() + { + var subscriptions = new List(); + foreach (var handler in DistributedEventBusOptions.Handlers) + { + foreach (var @interface in handler.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDistributedEventHandler<>))) + { + var eventType = @interface.GetGenericArguments()[0]; + var eventName = EventNameAttribute.GetNameOrDefault(eventType); + + subscriptions.Add(new DaprSubscriptionDefinition() + { + PubSubName = EventBusOptions.PubSubName, + Topic = eventName, + Route = AbpAspNetCoreDaprConsts.DaprEventCallbackUrl + }); + } + } + + if (Options.Contributors.Any()) + { + using (var scope = ServiceProvider.CreateScope()) + { + var context = new AbpDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions); + foreach (var contributor in Options.Contributors) + { + await contributor.ContributeAsync(context); + } + } + } + + return subscriptions; + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs new file mode 100644 index 0000000000..e2428e992a --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs @@ -0,0 +1,16 @@ +using Volo.Abp.AspNetCore.Dapr.Models; + +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpDaprPubSubProviderContributorContext +{ + public IServiceProvider ServiceProvider { get; } + + public List Subscriptions { get; } + + public AbpDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List daprSubscriptionModels) + { + ServiceProvider = serviceProvider; + Subscriptions = daprSubscriptionModels; + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs new file mode 100644 index 0000000000..b28fbf6e7a --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs @@ -0,0 +1,44 @@ +using System.Text.Json; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.AspNetCore.Dapr.Models; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Dapr; +using Volo.Abp.EventBus.Dapr; + +namespace Volo.Abp.AspNetCore.Dapr.Controllers; + +[Area("abp")] +[RemoteService(Name = "abp")] +public class DaprController : AbpController +{ + protected AbpDaprPubSubProvider DaprPubSubProvider { get; } + + public DaprController(AbpDaprPubSubProvider daprPubSubProvider) + { + DaprPubSubProvider = daprPubSubProvider; + } + + [HttpGet(AbpAspNetCoreDaprConsts.DaprSubscribeUrl)] + public virtual async Task> SubscribeAsync() + { + return await DaprPubSubProvider.GetSubscriptionsAsync(); + } + + [HttpPost(AbpAspNetCoreDaprConsts.DaprEventCallbackUrl)] + public virtual async Task EventsAsync() + { + var bodyJsonDocument = await JsonDocument.ParseAsync(HttpContext.Request.Body); + var request = JsonSerializer.Deserialize(bodyJsonDocument.RootElement.GetRawText(), + HttpContext.RequestServices.GetRequiredService>().Value.JsonSerializerOptions); + + var distributedEventBus = HttpContext.RequestServices.GetRequiredService(); + var daprSerializer = HttpContext.RequestServices.GetRequiredService(); + + var eventData = daprSerializer.Deserialize(bodyJsonDocument.RootElement.GetProperty("data").GetRawText(), distributedEventBus.GetEventType(request.Topic)); + await distributedEventBus.TriggerHandlersAsync(distributedEventBus.GetEventType(request.Topic), eventData); + + return Ok(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs new file mode 100644 index 0000000000..1a23483f9d --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public interface IAbpDaprPubSubProviderContributor +{ + Task ContributeAsync(AbpDaprPubSubProviderContributorContext context); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs new file mode 100644 index 0000000000..6fd8077250 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.AspNetCore.Dapr.Models; + +public class DaprSubscriptionDefinition +{ + public string PubSubName { get; set; } + + public string Topic { get; set; } + + public string Route { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs new file mode 100644 index 0000000000..9f7f4dfd4f --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs @@ -0,0 +1,8 @@ +namespace Volo.Abp.AspNetCore.Dapr.Models; + +public class DaprSubscriptionRequest +{ + public string PubSubName { get; set; } + + public string Topic { get; set; } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs new file mode 100644 index 0000000000..e682d283e9 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs @@ -0,0 +1,11 @@ +using System.Text.Json; + +namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; + +public class AbpAspNetCoreDaprJsonNamingPolicy : JsonNamingPolicy +{ + public override string ConvertName(string name) + { + return name.ToLower(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs new file mode 100644 index 0000000000..e2168da993 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs @@ -0,0 +1,25 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using Volo.Abp.AspNetCore.Dapr.Models; + +namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; + +public class DaprSubscriptionDefinitionConverter : JsonConverter +{ + private JsonSerializerOptions _writeJsonSerializerOptions; + + public override DaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + throw new NotSupportedException(); + } + + public override void Write(Utf8JsonWriter writer, DaprSubscriptionDefinition value, JsonSerializerOptions options) + { + _writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(new JsonSerializerOptions(options) + { + PropertyNamingPolicy = new AbpAspNetCoreDaprJsonNamingPolicy() + }, x => x == this); + + JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions); + } +} diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs index 1cd37ceb94..faaf450ddc 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprClientFactory.cs @@ -23,9 +23,13 @@ public class AbpDaprClientFactory : ITransientDependency public virtual async Task CreateAsync() { var builder = new DaprClientBuilder() - .UseHttpEndpoint(Options.HttpEndpoint) .UseJsonSerializationOptions(await CreateJsonSerializerOptions()); + if (!Options.HttpEndpoint.IsNullOrWhiteSpace()) + { + builder.UseHttpEndpoint(Options.HttpEndpoint); + } + if (!Options.GrpcEndpoint.IsNullOrWhiteSpace()) { builder.UseGrpcEndpoint(Options.GrpcEndpoint); diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs new file mode 100644 index 0000000000..7eec2c5c1c --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/IDaprSerializer.cs @@ -0,0 +1,16 @@ +namespace Volo.Abp.Dapr; + +public interface IDaprSerializer +{ + byte[] Serialize(object obj); + + object Deserialize(byte[] value, Type type); + + T Deserialize(byte[] value); + + string SerializeToString(object obj); + + object Deserialize(string value, Type type); + + T Deserialize(string value); +} diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs new file mode 100644 index 0000000000..ce9b4a8523 --- /dev/null +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/Utf8JsonDaprSerializer.cs @@ -0,0 +1,45 @@ +using System.Text; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Json; + +namespace Volo.Abp.Dapr; + +public class Utf8JsonDaprSerializer : IDaprSerializer, ITransientDependency +{ + private readonly IJsonSerializer _jsonSerializer; + + public Utf8JsonDaprSerializer(IJsonSerializer jsonSerializer) + { + _jsonSerializer = jsonSerializer; + } + + public byte[] Serialize(object obj) + { + return Encoding.UTF8.GetBytes(_jsonSerializer.Serialize(obj)); + } + + public object Deserialize(byte[] value, Type type) + { + return _jsonSerializer.Deserialize(type, Encoding.UTF8.GetString(value)); + } + + public T Deserialize(byte[] value) + { + return _jsonSerializer.Deserialize(Encoding.UTF8.GetString(value)); + } + + public string SerializeToString(object obj) + { + return _jsonSerializer.Serialize(obj); + } + + public object Deserialize(string value, Type type) + { + return _jsonSerializer.Deserialize(type, value); + } + + public T Deserialize(string value) + { + return _jsonSerializer.Deserialize(value); + } +} diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpDaprEventBusOptions.cs b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpDaprEventBusOptions.cs new file mode 100644 index 0000000000..d3ced52ba2 --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpDaprEventBusOptions.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.EventBus.Dapr; + +public class AbpDaprEventBusOptions +{ + public string PubSubName { get; set; } + + public AbpDaprEventBusOptions() + { + PubSubName = "pubsub"; + } +} diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs index 8d054c6bd7..5f6329a4bc 100644 --- a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/AbpEventBusDaprModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Dapr; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Dapr; using Volo.Abp.Modularity; namespace Volo.Abp.EventBus.Dapr; @@ -9,4 +10,11 @@ namespace Volo.Abp.EventBus.Dapr; )] public class AbpEventBusDaprModule : AbpModule { -} \ No newline at end of file + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + context + .ServiceProvider + .GetRequiredService() + .Initialize(); + } +} diff --git a/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs new file mode 100644 index 0000000000..1f241b9c6d --- /dev/null +++ b/framework/src/Volo.Abp.EventBus.Dapr/Volo/Abp/EventBus/Dapr/DaprDistributedEventBus.cs @@ -0,0 +1,221 @@ +using System.Collections.Concurrent; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.Dapr; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.Guids; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Threading; +using Volo.Abp.Timing; +using Volo.Abp.Uow; + +namespace Volo.Abp.EventBus.Dapr; + +[Dependency(ReplaceServices = true)] +[ExposeServices(typeof(IDistributedEventBus), typeof(DaprDistributedEventBus))] +public class DaprDistributedEventBus : DistributedEventBusBase, ISingletonDependency +{ + protected IDaprSerializer Serializer { get; } + protected AbpDaprEventBusOptions DaprEventBusOptions { get; } + protected AbpDaprClientFactory DaprClientFactory { get; } + + protected ConcurrentDictionary> HandlerFactories { get; } + protected ConcurrentDictionary EventTypes { get; } + + public DaprDistributedEventBus( + IServiceScopeFactory serviceScopeFactory, + ICurrentTenant currentTenant, + IUnitOfWorkManager unitOfWorkManager, + IOptions abpDistributedEventBusOptions, + IGuidGenerator guidGenerator, + IClock clock, + IEventHandlerInvoker eventHandlerInvoker, + IDaprSerializer serializer, + IOptions daprEventBusOptions, + AbpDaprClientFactory daprClientFactory) + : base(serviceScopeFactory, currentTenant, unitOfWorkManager, abpDistributedEventBusOptions, guidGenerator, clock, eventHandlerInvoker) + { + Serializer = serializer; + DaprEventBusOptions = daprEventBusOptions.Value; + DaprClientFactory = daprClientFactory; + + HandlerFactories = new ConcurrentDictionary>(); + EventTypes = new ConcurrentDictionary(); + } + + public void Initialize() + { + SubscribeHandlers(AbpDistributedEventBusOptions.Handlers); + } + + public override IDisposable Subscribe(Type eventType, IEventHandlerFactory factory) + { + var handlerFactories = GetOrCreateHandlerFactories(eventType); + + if (factory.IsInFactories(handlerFactories)) + { + return NullDisposable.Instance; + } + + handlerFactories.Add(factory); + + return new EventHandlerFactoryUnregistrar(this, eventType, factory); + } + + public override void Unsubscribe(Func action) + { + Check.NotNull(action, nameof(action)); + + GetOrCreateHandlerFactories(typeof(TEvent)) + .Locking(factories => + { + factories.RemoveAll( + factory => + { + var singleInstanceFactory = factory as SingleInstanceHandlerFactory; + if (singleInstanceFactory == null) + { + return false; + } + + var actionHandler = singleInstanceFactory.HandlerInstance as ActionEventHandler; + if (actionHandler == null) + { + return false; + } + + return actionHandler.Action == action; + }); + }); + } + + public override void Unsubscribe(Type eventType, IEventHandler handler) + { + GetOrCreateHandlerFactories(eventType) + .Locking(factories => + { + factories.RemoveAll( + factory => + factory is SingleInstanceHandlerFactory && + (factory as SingleInstanceHandlerFactory).HandlerInstance == handler + ); + }); + } + + public override void Unsubscribe(Type eventType, IEventHandlerFactory factory) + { + GetOrCreateHandlerFactories(eventType).Locking(factories => factories.Remove(factory)); + } + + public override void UnsubscribeAll(Type eventType) + { + GetOrCreateHandlerFactories(eventType).Locking(factories => factories.Clear()); + } + + protected async override Task PublishToEventBusAsync(Type eventType, object eventData) + { + await PublishToDaprAsync(eventType, eventData); + } + + protected override void AddToUnitOfWork(IUnitOfWork unitOfWork, UnitOfWorkEventRecord eventRecord) + { + unitOfWork.AddOrReplaceDistributedEvent(eventRecord); + } + + protected override IEnumerable GetHandlerFactories(Type eventType) + { + var handlerFactoryList = new List(); + + foreach (var handlerFactory in HandlerFactories.Where(hf => ShouldTriggerEventForHandler(eventType, hf.Key))) + { + handlerFactoryList.Add(new EventTypeWithEventHandlerFactories(handlerFactory.Key, handlerFactory.Value)); + } + + return handlerFactoryList.ToArray(); + } + + public async override Task PublishFromOutboxAsync(OutgoingEventInfo outgoingEvent, OutboxConfig outboxConfig) + { + await PublishToDaprAsync(outgoingEvent.EventName, Serializer.Deserialize(outgoingEvent.EventData, GetEventType(outgoingEvent.EventName))); + } + + public async override Task PublishManyFromOutboxAsync(IEnumerable outgoingEvents, OutboxConfig outboxConfig) + { + var outgoingEventArray = outgoingEvents.ToArray(); + + foreach (var outgoingEvent in outgoingEventArray) + { + await PublishToDaprAsync(outgoingEvent.EventName, Serializer.Deserialize(outgoingEvent.EventData, GetEventType(outgoingEvent.EventName))); + } + } + + public async override Task ProcessFromInboxAsync(IncomingEventInfo incomingEvent, InboxConfig inboxConfig) + { + var eventType = EventTypes.GetOrDefault(incomingEvent.EventName); + if (eventType == null) + { + return; + } + + var eventData = Serializer.Deserialize(incomingEvent.EventData, eventType); + var exceptions = new List(); + await TriggerHandlersAsync(eventType, eventData, exceptions, inboxConfig); + if (exceptions.Any()) + { + ThrowOriginalExceptions(eventType, exceptions); + } + } + + protected override byte[] Serialize(object eventData) + { + return Serializer.Serialize(eventData); + } + + private List GetOrCreateHandlerFactories(Type eventType) + { + return HandlerFactories.GetOrAdd( + eventType, + type => + { + var eventName = EventNameAttribute.GetNameOrDefault(type); + EventTypes[eventName] = type; + return new List(); + } + ); + } + + public Type GetEventType(string eventName) + { + return EventTypes.GetOrDefault(eventName); + } + + protected virtual async Task PublishToDaprAsync(Type eventType, object eventData) + { + await PublishToDaprAsync(EventNameAttribute.GetNameOrDefault(eventType), eventData); + } + + protected virtual async Task PublishToDaprAsync(string eventName, object eventData) + { + var client = await DaprClientFactory.CreateAsync(); + await client.PublishEventAsync(pubsubName: DaprEventBusOptions.PubSubName, topicName: eventName, data: eventData); + } + + private static bool ShouldTriggerEventForHandler(Type targetEventType, Type handlerEventType) + { + //Should trigger same type + if (handlerEventType == targetEventType) + { + return true; + } + + //TODO: Support inheritance? But it does not support on subscription to RabbitMq! + //Should trigger for inherited types + if (handlerEventType.IsAssignableFrom(targetEventType)) + { + return true; + } + + return false; + } +} From bccd1155906b0a0c34a711e3f27165516c9432fe Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 9 Aug 2022 18:04:45 +0800 Subject: [PATCH 013/106] Implement the Dapr http client --- .../Http/Client/Dapr/AbpDaprClientOptions.cs | 24 +++++++++++++++++++ .../Client/Dapr/AbpHttpClientDaprModule.cs | 20 +++++++++++++--- ...viceCollectionHttpClientProxyExtensions.cs | 2 +- 3 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs new file mode 100644 index 0000000000..b2504acd9c --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs @@ -0,0 +1,24 @@ +using Dapr.Client; +using Microsoft.Extensions.DependencyInjection; + +namespace Volo.Abp.Http.Client.Dapr; + +public class AbpDaprClientOptions +{ + public Action DaprHttpClientBuilderAction { get; set; } + + public AbpDaprClientOptions() + { + DaprHttpClientBuilderAction = DefaultDaprHttpClientBuilder; + } + + private void DefaultDaprHttpClientBuilder(string serviceName, IHttpClientBuilder clientBuilder, string daprEndpoint) + { + Check.NotNull(daprEndpoint, nameof(daprEndpoint)); + + clientBuilder.AddHttpMessageHandler(() => new InvocationHandler + { + DaprEndpoint = daprEndpoint + }); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs index 8d9a73290f..1b24510842 100644 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Dapr; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Dapr; using Volo.Abp.Modularity; namespace Volo.Abp.Http.Client.Dapr; @@ -6,7 +7,20 @@ namespace Volo.Abp.Http.Client.Dapr; [DependsOn( typeof(AbpHttpClientModule), typeof(AbpDaprModule) - )] +)] public class AbpHttpClientDaprModule : AbpModule -{ +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + var daprOptions = context.Services.ExecutePreConfiguredActions(); + var daprClientOptions = context.Services.ExecutePreConfiguredActions(); + + PreConfigure(options => + { + options.ProxyClientBuildActions.Add((_, clientBuilder) => + { + daprClientOptions.DaprHttpClientBuilderAction(_, clientBuilder, daprOptions.HttpEndpoint); + }); + }); + } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs index 4ccac104cd..7bc239813d 100644 --- a/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs +++ b/framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionHttpClientProxyExtensions.cs @@ -212,7 +212,7 @@ public static class ServiceCollectionHttpClientProxyExtensions } /// - /// Checks wether the type is suitable to use with the proxying. + /// Checks whether the type is suitable to use with the proxying. /// Currently the type is checked statically against some fixed conditions. /// /// Type to check From c559fa4335d7f8909319f1c5d5a075c484353943 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Tue, 9 Aug 2022 20:25:25 +0800 Subject: [PATCH 014/106] Add AbpInvocationHandler --- .../Abp/Http/Client/Dapr/AbpDaprClientOptions.cs | 14 ++++---------- .../Http/Client/Dapr/AbpHttpClientDaprModule.cs | 3 +-- .../Abp/Http/Client/Dapr/AbpInvocationHandler.cs | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs index b2504acd9c..e6fa2d35dd 100644 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpDaprClientOptions.cs @@ -1,24 +1,18 @@ -using Dapr.Client; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; namespace Volo.Abp.Http.Client.Dapr; public class AbpDaprClientOptions { - public Action DaprHttpClientBuilderAction { get; set; } + public Action DaprHttpClientBuilderAction { get; set; } public AbpDaprClientOptions() { DaprHttpClientBuilderAction = DefaultDaprHttpClientBuilder; } - private void DefaultDaprHttpClientBuilder(string serviceName, IHttpClientBuilder clientBuilder, string daprEndpoint) + private void DefaultDaprHttpClientBuilder(string serviceName, IHttpClientBuilder clientBuilder) { - Check.NotNull(daprEndpoint, nameof(daprEndpoint)); - - clientBuilder.AddHttpMessageHandler(() => new InvocationHandler - { - DaprEndpoint = daprEndpoint - }); + clientBuilder.AddHttpMessageHandler(); } } \ No newline at end of file diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs index 1b24510842..374fca198e 100644 --- a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpHttpClientDaprModule.cs @@ -12,14 +12,13 @@ public class AbpHttpClientDaprModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - var daprOptions = context.Services.ExecutePreConfiguredActions(); var daprClientOptions = context.Services.ExecutePreConfiguredActions(); PreConfigure(options => { options.ProxyClientBuildActions.Add((_, clientBuilder) => { - daprClientOptions.DaprHttpClientBuilderAction(_, clientBuilder, daprOptions.HttpEndpoint); + daprClientOptions.DaprHttpClientBuilderAction(_, clientBuilder); }); }); } diff --git a/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs new file mode 100644 index 0000000000..a3397b55e4 --- /dev/null +++ b/framework/src/Volo.Abp.Http.Client.Dapr/Volo/Abp/Http/Client/Dapr/AbpInvocationHandler.cs @@ -0,0 +1,14 @@ +using Dapr.Client; +using Microsoft.Extensions.Options; +using Volo.Abp.Dapr; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.Http.Client.Dapr; + +public class AbpInvocationHandler : InvocationHandler, ITransientDependency +{ + public AbpInvocationHandler(IOptions daprOptions) + { + DaprEndpoint = daprOptions.Value.HttpEndpoint; + } +} \ No newline at end of file From 4d6987a99f269817832d763b666209df47755f34 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 11 Aug 2022 16:06:38 +0800 Subject: [PATCH 015/106] Add `framework/src/Volo.Abp.AspNetCore.Dapr.EventBus` package. --- framework/Volo.Abp.sln | 7 ++++ .../FodyWeavers.xml | 3 ++ .../FodyWeavers.xsd | 30 +++++++++++++++++ .../Volo.Abp.AspNetCore.Dapr.EventBus.csproj | 17 ++++++++++ .../AbpAspNetCoreDaprEventBusModule.cs | 31 ++++++++++++++++++ .../AbpAspNetCoreDaprEventBusOptions.cs | 11 +++++++ .../AbpAspNetCoreDaprPubSubConsts.cs} | 2 +- .../AbpAspNetCoreDaprPubSubProvider.cs} | 32 +++++++++---------- ...oreDaprPubSubProviderContributorContext.cs | 16 ++++++++++ .../AbpAspNetCoreDaprPubSubController.cs} | 19 ++++------- ...AspNetCoreDaprPubSubProviderContributor.cs | 6 ++++ ...bpAspNetCoreDaprSubscriptionDefinition.cs} | 2 +- .../AbpAspNetCoreDaprSubscriptionRequest.cs} | 2 +- ...bpAspNetCoreDaprPubSubJsonNamingPolicy.cs} | 2 +- ...oreDaprSubscriptionDefinitionConverter.cs} | 8 ++--- .../Volo.Abp.AspNetCore.Dapr.csproj | 7 ---- .../Dapr/AbpAspNetCoreDaprModule.cs | 25 ++------------- .../Dapr/AbpAspNetCoreDaprOptions.cs | 11 ------- ...AbpDaprPubSubProviderContributorContext.cs | 16 ---------- .../Dapr/IAbpDaprPubSubProviderContributor.cs | 6 ---- nupkg/common.ps1 | 1 + 21 files changed, 155 insertions(+), 99 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs} (80%) rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs} (54%) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs} (65%) create mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs} (76%) rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs} (72%) rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs} (71%) rename framework/src/{Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs => Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs} (52%) delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs delete mode 100644 framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index b97935b3c1..5578e2d7c3 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -417,6 +417,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Http.Client.Dapr", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr", "src\Volo.Abp.AspNetCore.Dapr\Volo.Abp.AspNetCore.Dapr.csproj", "{5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr.EventBus", "src\Volo.Abp.AspNetCore.Dapr.EventBus\Volo.Abp.AspNetCore.Dapr.EventBus.csproj", "{B02EF042-C39E-45C4-A92D-BF7554E1889D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1243,6 +1245,10 @@ Global {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Debug|Any CPU.Build.0 = Debug|Any CPU {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.ActiveCfg = Release|Any CPU {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1}.Release|Any CPU.Build.0 = Release|Any CPU + {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1453,6 +1459,7 @@ Global {DCC41E99-EBC7-4F19-BA0D-A6F770D8E431} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {18B796D2-D45D-41AE-9A42-75C9B14B20DF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {B02EF042-C39E-45C4-A92D-BF7554E1889D} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml new file mode 100644 index 0000000000..be0de3a908 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xsd b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/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/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj new file mode 100644 index 0000000000..0c9280a27e --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo.Abp.AspNetCore.Dapr.EventBus.csproj @@ -0,0 +1,17 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs new file mode 100644 index 0000000000..b4fd636e76 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusModule.cs @@ -0,0 +1,31 @@ +using Microsoft.AspNetCore.Http.Json; +using Volo.Abp.AspNetCore.Dapr.SystemTextJson; +using Volo.Abp.EventBus.Dapr; +using Volo.Abp.Json; +using Volo.Abp.Json.SystemTextJson; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Dapr; + +[DependsOn( + typeof(AbpAspNetCoreDaprModule), + typeof(AbpEventBusDaprModule), + typeof(AbpJsonModule) + )] +public class AbpAspNetCoreDaprEventBusModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + // TODO: Add NewtonsoftJson json converter. + + Configure(options => + { + options.SerializerOptions.Converters.Add(new AbpAspNetCoreDaprSubscriptionDefinitionConverter()); + }); + + Configure(options => + { + options.JsonSerializerOptions.Converters.Add(new AbpAspNetCoreDaprSubscriptionDefinitionConverter()); + }); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs new file mode 100644 index 0000000000..be65464428 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprEventBusOptions.cs @@ -0,0 +1,11 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpAspNetCoreDaprEventBusOptions +{ + public List Contributors { get; } + + public AbpAspNetCoreDaprEventBusOptions() + { + Contributors = new List(); + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs similarity index 80% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs index 7011d25476..c0cfb9d5cc 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprConsts.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubConsts.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.AspNetCore.Dapr; -public class AbpAspNetCoreDaprConsts +public class AbpAspNetCoreDaprPubSubConsts { public const string DaprSubscribeUrl = "dapr/subscribe"; diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs similarity index 54% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs index 27eaa294d5..0affd70bba 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProvider.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProvider.cs @@ -8,28 +8,28 @@ using Volo.Abp.EventBus.Distributed; namespace Volo.Abp.AspNetCore.Dapr; -public class AbpDaprPubSubProvider : ITransientDependency +public class AbpAspNetCoreDaprPubSubProvider : ITransientDependency { protected IServiceProvider ServiceProvider { get; } - protected AbpAspNetCoreDaprOptions Options { get; } - protected AbpDaprEventBusOptions EventBusOptions { get; } + protected AbpAspNetCoreDaprEventBusOptions AspNetCoreDaprEventBusOptions { get; } + protected AbpDaprEventBusOptions DaprEventBusOptions { get; } protected AbpDistributedEventBusOptions DistributedEventBusOptions { get; } - public AbpDaprPubSubProvider( + public AbpAspNetCoreDaprPubSubProvider( IServiceProvider serviceProvider, - IOptions options, - IOptions eventBusOptions, + IOptions aspNetCoreDaprEventBusOptions, + IOptions daprEventBusOptions, IOptions distributedEventBusOptions) { ServiceProvider = serviceProvider; - EventBusOptions = eventBusOptions.Value; - Options = options.Value; + AspNetCoreDaprEventBusOptions = aspNetCoreDaprEventBusOptions.Value; + DaprEventBusOptions = daprEventBusOptions.Value; DistributedEventBusOptions = distributedEventBusOptions.Value; } - public virtual async Task> GetSubscriptionsAsync() + public virtual async Task> GetSubscriptionsAsync() { - var subscriptions = new List(); + var subscriptions = new List(); foreach (var handler in DistributedEventBusOptions.Handlers) { foreach (var @interface in handler.GetInterfaces().Where(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IDistributedEventHandler<>))) @@ -37,21 +37,21 @@ public class AbpDaprPubSubProvider : ITransientDependency var eventType = @interface.GetGenericArguments()[0]; var eventName = EventNameAttribute.GetNameOrDefault(eventType); - subscriptions.Add(new DaprSubscriptionDefinition() + subscriptions.Add(new AbpAspNetCoreDaprSubscriptionDefinition() { - PubSubName = EventBusOptions.PubSubName, + PubSubName = DaprEventBusOptions.PubSubName, Topic = eventName, - Route = AbpAspNetCoreDaprConsts.DaprEventCallbackUrl + Route = AbpAspNetCoreDaprPubSubConsts.DaprEventCallbackUrl }); } } - if (Options.Contributors.Any()) + if (AspNetCoreDaprEventBusOptions.Contributors.Any()) { using (var scope = ServiceProvider.CreateScope()) { - var context = new AbpDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions); - foreach (var contributor in Options.Contributors) + var context = new AbpAspNetCoreDaprPubSubProviderContributorContext(scope.ServiceProvider, subscriptions); + foreach (var contributor in AspNetCoreDaprEventBusOptions.Contributors) { await contributor.ContributeAsync(context); } diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs new file mode 100644 index 0000000000..93cb43b0bf --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/AbpAspNetCoreDaprPubSubProviderContributorContext.cs @@ -0,0 +1,16 @@ +using Volo.Abp.AspNetCore.Dapr.Models; + +namespace Volo.Abp.AspNetCore.Dapr; + +public class AbpAspNetCoreDaprPubSubProviderContributorContext +{ + public IServiceProvider ServiceProvider { get; } + + public List Subscriptions { get; } + + public AbpAspNetCoreDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List daprSubscriptionModels) + { + ServiceProvider = serviceProvider; + Subscriptions = daprSubscriptionModels; + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs similarity index 65% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs index b28fbf6e7a..e2440d90ce 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Controllers/DaprController.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Controllers/AbpAspNetCoreDaprPubSubController.cs @@ -11,26 +11,19 @@ namespace Volo.Abp.AspNetCore.Dapr.Controllers; [Area("abp")] [RemoteService(Name = "abp")] -public class DaprController : AbpController +public class AbpAspNetCoreDaprPubSubController : AbpController { - protected AbpDaprPubSubProvider DaprPubSubProvider { get; } - - public DaprController(AbpDaprPubSubProvider daprPubSubProvider) - { - DaprPubSubProvider = daprPubSubProvider; - } - - [HttpGet(AbpAspNetCoreDaprConsts.DaprSubscribeUrl)] - public virtual async Task> SubscribeAsync() + [HttpGet(AbpAspNetCoreDaprPubSubConsts.DaprSubscribeUrl)] + public virtual async Task> SubscribeAsync() { - return await DaprPubSubProvider.GetSubscriptionsAsync(); + return await HttpContext.RequestServices.GetRequiredService().GetSubscriptionsAsync(); } - [HttpPost(AbpAspNetCoreDaprConsts.DaprEventCallbackUrl)] + [HttpPost(AbpAspNetCoreDaprPubSubConsts.DaprEventCallbackUrl)] public virtual async Task EventsAsync() { var bodyJsonDocument = await JsonDocument.ParseAsync(HttpContext.Request.Body); - var request = JsonSerializer.Deserialize(bodyJsonDocument.RootElement.GetRawText(), + var request = JsonSerializer.Deserialize(bodyJsonDocument.RootElement.GetRawText(), HttpContext.RequestServices.GetRequiredService>().Value.JsonSerializerOptions); var distributedEventBus = HttpContext.RequestServices.GetRequiredService(); diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs new file mode 100644 index 0000000000..da9f7564de --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/IAbpAspNetCoreDaprPubSubProviderContributor.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.AspNetCore.Dapr; + +public interface IAbpAspNetCoreDaprPubSubProviderContributor +{ + Task ContributeAsync(AbpAspNetCoreDaprPubSubProviderContributorContext context); +} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs similarity index 76% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs index 6fd8077250..414a69fbf1 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionDefinition.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionDefinition.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.AspNetCore.Dapr.Models; -public class DaprSubscriptionDefinition +public class AbpAspNetCoreDaprSubscriptionDefinition { public string PubSubName { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs similarity index 72% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs index 9f7f4dfd4f..1dd88b1015 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/Models/DaprSubscriptionRequest.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/Models/AbpAspNetCoreDaprSubscriptionRequest.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.AspNetCore.Dapr.Models; -public class DaprSubscriptionRequest +public class AbpAspNetCoreDaprSubscriptionRequest { public string PubSubName { get; set; } diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs similarity index 71% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs index e682d283e9..f6d4605ff2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/AbpAspNetCoreDaprJsonNamingPolicy.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprPubSubJsonNamingPolicy.cs @@ -2,7 +2,7 @@ namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; -public class AbpAspNetCoreDaprJsonNamingPolicy : JsonNamingPolicy +public class AbpAspNetCoreDaprPubSubJsonNamingPolicy : JsonNamingPolicy { public override string ConvertName(string name) { diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs similarity index 52% rename from framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs rename to framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs index e2168da993..c0699ece43 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/SystemTextJson/DaprSubscriptionDefinitionConverter.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr.EventBus/Volo/Abp/AspNetCore/Dapr/EventBus/SystemTextJson/AbpAspNetCoreDaprSubscriptionDefinitionConverter.cs @@ -4,20 +4,20 @@ using Volo.Abp.AspNetCore.Dapr.Models; namespace Volo.Abp.AspNetCore.Dapr.SystemTextJson; -public class DaprSubscriptionDefinitionConverter : JsonConverter +public class AbpAspNetCoreDaprSubscriptionDefinitionConverter : JsonConverter { private JsonSerializerOptions _writeJsonSerializerOptions; - public override DaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override AbpAspNetCoreDaprSubscriptionDefinition Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { throw new NotSupportedException(); } - public override void Write(Utf8JsonWriter writer, DaprSubscriptionDefinition value, JsonSerializerOptions options) + public override void Write(Utf8JsonWriter writer, AbpAspNetCoreDaprSubscriptionDefinition value, JsonSerializerOptions options) { _writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(new JsonSerializerOptions(options) { - PropertyNamingPolicy = new AbpAspNetCoreDaprJsonNamingPolicy() + PropertyNamingPolicy = new AbpAspNetCoreDaprPubSubJsonNamingPolicy() }, x => x == this); JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions); diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj index 747593eb3f..51c2a097b9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo.Abp.AspNetCore.Dapr.csproj @@ -12,17 +12,10 @@ - - - - - - - diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs index 52e5820c4c..1650efa667 100644 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprModule.cs @@ -1,31 +1,12 @@ -using Microsoft.AspNetCore.Http.Json; -using Volo.Abp.AspNetCore.Dapr.SystemTextJson; -using Volo.Abp.EventBus.Dapr; -using Volo.Abp.Json; -using Volo.Abp.Json.SystemTextJson; +using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Dapr; [DependsOn( - typeof(AbpAspNetCoreModule), - typeof(AbpEventBusDaprModule), - typeof(AbpJsonModule) - )] + typeof(AbpAspNetCoreMvcModule) +)] public class AbpAspNetCoreDaprModule : AbpModule { - public override void ConfigureServices(ServiceConfigurationContext context) - { - // TODO: Add NewtonsoftJson json converter. - Configure(options => - { - options.SerializerOptions.Converters.Add(new DaprSubscriptionDefinitionConverter()); - }); - - Configure(options => - { - options.JsonSerializerOptions.Converters.Add(new DaprSubscriptionDefinitionConverter()); - }); - } } diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs deleted file mode 100644 index 17667d24b9..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpAspNetCoreDaprOptions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace Volo.Abp.AspNetCore.Dapr; - -public class AbpAspNetCoreDaprOptions -{ - public List Contributors { get; } - - public AbpAspNetCoreDaprOptions() - { - Contributors = new List(); - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs deleted file mode 100644 index e2428e992a..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/AbpDaprPubSubProviderContributorContext.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Volo.Abp.AspNetCore.Dapr.Models; - -namespace Volo.Abp.AspNetCore.Dapr; - -public class AbpDaprPubSubProviderContributorContext -{ - public IServiceProvider ServiceProvider { get; } - - public List Subscriptions { get; } - - public AbpDaprPubSubProviderContributorContext(IServiceProvider serviceProvider, List daprSubscriptionModels) - { - ServiceProvider = serviceProvider; - Subscriptions = daprSubscriptionModels; - } -} diff --git a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs b/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs deleted file mode 100644 index 1a23483f9d..0000000000 --- a/framework/src/Volo.Abp.AspNetCore.Dapr/Volo/Abp/AspNetCore/Dapr/IAbpDaprPubSubProviderContributor.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Volo.Abp.AspNetCore.Dapr; - -public interface IAbpDaprPubSubProviderContributor -{ - Task ContributeAsync(AbpDaprPubSubProviderContributorContext context); -} diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index c020554e5e..a2df36ae42 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -100,6 +100,7 @@ $projects = ( "framework/src/Volo.Abp.AspNetCore.Authentication.OpenIdConnect", "framework/src/Volo.Abp.AspNetCore", "framework/src/Volo.Abp.AspNetCore.Dapr", + "framework/src/Volo.Abp.AspNetCore.Dapr.EventBus", "framework/src/Volo.Abp.AspNetCore.Components", "framework/src/Volo.Abp.AspNetCore.Components.Server", "framework/src/Volo.Abp.AspNetCore.Components.Web", From b7d5ad768ac49d60b418b7a0e538f7f0ff440a68 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 11 Aug 2022 18:15:55 +0800 Subject: [PATCH 016/106] Implement the Dapr DistributedLock --- framework/Volo.Abp.sln | 7 +++ .../Volo/Abp/Dapr/AbpDaprOptions.cs | 2 + .../FodyWeavers.xml | 3 ++ .../FodyWeavers.xsd | 30 +++++++++++ .../Volo.Abp.DistributedLocking.Dapr.csproj | 18 +++++++ .../Dapr/AbpDistributedLockDaprOptions.cs | 6 +++ .../Dapr/AbpDistributedLockingDaprModule.cs | 11 ++++ .../Dapr/DaprAbpDistributedLock.cs | 50 +++++++++++++++++++ .../Dapr/DaprAbpDistributedLockHandle.cs | 18 +++++++ .../AbpDistributedLockingModule.cs | 1 - nupkg/common.ps1 | 1 + 11 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xsd create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs create mode 100644 framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln index 5578e2d7c3..f6eba4386d 100644 --- a/framework/Volo.Abp.sln +++ b/framework/Volo.Abp.sln @@ -419,6 +419,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Dapr.EventBus", "src\Volo.Abp.AspNetCore.Dapr.EventBus\Volo.Abp.AspNetCore.Dapr.EventBus.csproj", "{B02EF042-C39E-45C4-A92D-BF7554E1889D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.DistributedLocking.Dapr", "src\Volo.Abp.DistributedLocking.Dapr\Volo.Abp.DistributedLocking.Dapr.csproj", "{CAE48068-233C-47A9-BEAB-DDF521730E7A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1249,6 +1251,10 @@ Global {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Debug|Any CPU.Build.0 = Debug|Any CPU {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.ActiveCfg = Release|Any CPU {B02EF042-C39E-45C4-A92D-BF7554E1889D}.Release|Any CPU.Build.0 = Release|Any CPU + {CAE48068-233C-47A9-BEAB-DDF521730E7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CAE48068-233C-47A9-BEAB-DDF521730E7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CAE48068-233C-47A9-BEAB-DDF521730E7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CAE48068-233C-47A9-BEAB-DDF521730E7A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1460,6 +1466,7 @@ Global {18B796D2-D45D-41AE-9A42-75C9B14B20DF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {5EED625D-8D86-492A-BCB8-F6C8CD8D4AA1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {B02EF042-C39E-45C4-A92D-BF7554E1889D} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} + {CAE48068-233C-47A9-BEAB-DDF521730E7A} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs index e6919783af..9d743263c5 100644 --- a/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs +++ b/framework/src/Volo.Abp.Dapr/Volo/Abp/Dapr/AbpDaprOptions.cs @@ -2,6 +2,8 @@ public class AbpDaprOptions { + public string AppId { get; set; } + public string HttpEndpoint { get; set; } public string GrpcEndpoint { get; set; } diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml b/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml new file mode 100644 index 0000000000..00e1d9a1c1 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xsd b/framework/src/Volo.Abp.DistributedLocking.Dapr/FodyWeavers.xsd new file mode 100644 index 0000000000..3f3946e282 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/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/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj new file mode 100644 index 0000000000..80cad677a3 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo.Abp.DistributedLocking.Dapr.csproj @@ -0,0 +1,18 @@ + + + + + + + net6.0 + enable + enable + + + + + + + + + diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs new file mode 100644 index 0000000000..a2ff732932 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs @@ -0,0 +1,6 @@ +namespace Volo.Abp.DistributedLocking.Dapr; + +public class AbpDistributedLockDaprOptions +{ + public string StoreName { get; set; } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs new file mode 100644 index 0000000000..c915cfe2f7 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockingDaprModule.cs @@ -0,0 +1,11 @@ +using Volo.Abp.Dapr; +using Volo.Abp.Modularity; + +namespace Volo.Abp.DistributedLocking.Dapr; + +[DependsOn( + typeof(AbpDistributedLockingAbstractionsModule), + typeof(AbpDaprModule))] +public class AbpDistributedLockingDaprModule : AbpModule +{ +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs new file mode 100644 index 0000000000..d74d7497fc --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs @@ -0,0 +1,50 @@ +using Microsoft.Extensions.Options; +using Volo.Abp.Dapr; +using Volo.Abp.DependencyInjection; + +namespace Volo.Abp.DistributedLocking.Dapr; + +[Dependency(ReplaceServices = true)] +public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency +{ + protected AbpDaprClientFactory DaprClientFactory { get; } + protected AbpDistributedLockDaprOptions DistributedLockDaprOptions { get; } + protected AbpDaprOptions DaprOptions { get; } + + public DaprAbpDistributedLock( + AbpDaprClientFactory daprClientFactory, + IOptions distributedLockDaprOptions, + IOptions daprOptions) + { + DaprClientFactory = daprClientFactory; + DaprOptions = daprOptions.Value; + DistributedLockDaprOptions = distributedLockDaprOptions.Value; + } + + public async Task TryAcquireAsync( + string name, + TimeSpan timeout = default, + CancellationToken cancellationToken = default) + { + if (timeout == default) + { + timeout = TimeSpan.FromSeconds(30); + } + + var daprClient = await DaprClientFactory.CreateAsync(); + + var lockResponse = await daprClient.Lock( + DistributedLockDaprOptions.StoreName, + name, + DaprOptions.AppId, + timeout.Seconds, + cancellationToken); + + if (lockResponse == null || !lockResponse.Success) + { + return null; + } + + return new DaprAbpDistributedLockHandle(lockResponse); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs new file mode 100644 index 0000000000..b10f0f3672 --- /dev/null +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLockHandle.cs @@ -0,0 +1,18 @@ +using Dapr.Client; + +namespace Volo.Abp.DistributedLocking.Dapr; + +public class DaprAbpDistributedLockHandle : IAbpDistributedLockHandle +{ + protected TryLockResponse LockResponse { get; } + + public DaprAbpDistributedLockHandle(TryLockResponse lockResponse) + { + LockResponse = lockResponse; + } + + public async ValueTask DisposeAsync() + { + await LockResponse.DisposeAsync(); + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking/Volo/Abp/DistributedLocking/AbpDistributedLockingModule.cs b/framework/src/Volo.Abp.DistributedLocking/Volo/Abp/DistributedLocking/AbpDistributedLockingModule.cs index 4c4abd3f32..c642e33667 100644 --- a/framework/src/Volo.Abp.DistributedLocking/Volo/Abp/DistributedLocking/AbpDistributedLockingModule.cs +++ b/framework/src/Volo.Abp.DistributedLocking/Volo/Abp/DistributedLocking/AbpDistributedLockingModule.cs @@ -7,5 +7,4 @@ namespace Volo.Abp.DistributedLocking; )] public class AbpDistributedLockingModule : AbpModule { - } diff --git a/nupkg/common.ps1 b/nupkg/common.ps1 index a2df36ae42..65e2d46324 100644 --- a/nupkg/common.ps1 +++ b/nupkg/common.ps1 @@ -164,6 +164,7 @@ $projects = ( "framework/src/Volo.Abp.Ddd.Domain", "framework/src/Volo.Abp.DistributedLocking.Abstractions", "framework/src/Volo.Abp.DistributedLocking", + "framework/src/Volo.Abp.DistributedLocking.Dapr", "framework/src/Volo.Abp.Emailing", "framework/src/Volo.Abp.EntityFrameworkCore", "framework/src/Volo.Abp.EntityFrameworkCore.MySQL", From 04d39d24d3a3f419d46784f6753da68b5e2e23c2 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Thu, 11 Aug 2022 15:01:41 +0300 Subject: [PATCH 017/106] Add Current-user.md for Angular --- docs/en/UI/Angular/Current-User.md | 20 ++++++++++++++++++++ docs/en/docs-nav.json | 4 ++++ 2 files changed, 24 insertions(+) create mode 100644 docs/en/UI/Angular/Current-User.md diff --git a/docs/en/UI/Angular/Current-User.md b/docs/en/UI/Angular/Current-User.md new file mode 100644 index 0000000000..0d0f9c024c --- /dev/null +++ b/docs/en/UI/Angular/Current-User.md @@ -0,0 +1,20 @@ +# Angular UI: Current User + +Current user information store in Config State. + +### How to Get a Current User Information Configuration + +You can use the `getOne` or `getOne$` method of `ConfigStateService` to get a specific configuration property. For that, the property name should be passed to the method as parameter. + +```js +// this.config is instance of ConfigStateService + +const currentUser = this.config.getOne("currentUser"); + +// or +this.config.getOne$("currentUser").subscribe(currentUser => { + // use currentUser here +}) +``` + +> See the [ConfigStateService](./Config-State-Service) for more information. diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index db63a7136b..f124e7ead7 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -977,6 +977,10 @@ "text": "Authorization", "path": "UI/Angular/Authorization.md" }, + { + "text": "Current User", + "path": "UI/Angular/Current-User.md" + }, { "text": "HTTP Requests", "path": "UI/Angular/HTTP-Requests.md" From e9d3919ccc8fcccc5aee7cc7fda120bfc501fff1 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Thu, 11 Aug 2022 15:02:56 +0300 Subject: [PATCH 018/106] Update Current-User.md --- docs/en/UI/Angular/Current-User.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/UI/Angular/Current-User.md b/docs/en/UI/Angular/Current-User.md index 0d0f9c024c..26ca4834b8 100644 --- a/docs/en/UI/Angular/Current-User.md +++ b/docs/en/UI/Angular/Current-User.md @@ -1,6 +1,6 @@ # Angular UI: Current User -Current user information store in Config State. +The current user information store in Config State. ### How to Get a Current User Information Configuration From ecd834ca3524be8645e4947e8cd78eb50769626b Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 11 Aug 2022 20:37:30 +0800 Subject: [PATCH 019/106] Add DefaultTimeout --- .../DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs | 2 ++ .../Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs index a2ff732932..6938300f9b 100644 --- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs @@ -3,4 +3,6 @@ public class AbpDistributedLockDaprOptions { public string StoreName { get; set; } + + public TimeSpan DefaultTimeout { get; set;} } \ No newline at end of file diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs index d74d7497fc..7f95a56542 100644 --- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/DaprAbpDistributedLock.cs @@ -28,7 +28,7 @@ public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency { if (timeout == default) { - timeout = TimeSpan.FromSeconds(30); + timeout = DistributedLockDaprOptions.DefaultTimeout; } var daprClient = await DaprClientFactory.CreateAsync(); @@ -37,7 +37,7 @@ public class DaprAbpDistributedLock : IAbpDistributedLock, ITransientDependency DistributedLockDaprOptions.StoreName, name, DaprOptions.AppId, - timeout.Seconds, + (int)timeout.TotalSeconds, cancellationToken); if (lockResponse == null || !lockResponse.Success) From 47431aad449deb65d047358aa48d9ec36ae64695 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 11 Aug 2022 20:38:16 +0800 Subject: [PATCH 020/106] Update AbpDistributedLockDaprOptions --- .../Dapr/AbpDistributedLockDaprOptions.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs index 6938300f9b..43feba3c3b 100644 --- a/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs +++ b/framework/src/Volo.Abp.DistributedLocking.Dapr/Volo/Abp/DistributedLocking/Dapr/AbpDistributedLockDaprOptions.cs @@ -4,5 +4,10 @@ public class AbpDistributedLockDaprOptions { public string StoreName { get; set; } - public TimeSpan DefaultTimeout { get; set;} + public TimeSpan DefaultTimeout { get; set; } + + public AbpDistributedLockDaprOptions() + { + DefaultTimeout = TimeSpan.FromSeconds(30); + } } \ No newline at end of file From a9f457eb25e498d1c3f2bb304d85bec551addf28 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Fri, 12 Aug 2022 14:59:03 +0300 Subject: [PATCH 021/106] Update Current-User.md --- docs/en/UI/Angular/Current-User.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/UI/Angular/Current-User.md b/docs/en/UI/Angular/Current-User.md index 26ca4834b8..90db8d12fa 100644 --- a/docs/en/UI/Angular/Current-User.md +++ b/docs/en/UI/Angular/Current-User.md @@ -1,6 +1,6 @@ # Angular UI: Current User -The current user information store in Config State. +The current user information stored in Config State. ### How to Get a Current User Information Configuration From 605a4538958c3153f801feded6350854cba0032c Mon Sep 17 00:00:00 2001 From: Hamza Albreem <94292623+braim23@users.noreply.github.com> Date: Fri, 12 Aug 2022 15:09:53 +0300 Subject: [PATCH 022/106] tiny addition --- docs/en/UI/Angular/Current-User.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/UI/Angular/Current-User.md b/docs/en/UI/Angular/Current-User.md index 90db8d12fa..820a787b5c 100644 --- a/docs/en/UI/Angular/Current-User.md +++ b/docs/en/UI/Angular/Current-User.md @@ -7,7 +7,7 @@ The current user information stored in Config State. You can use the `getOne` or `getOne$` method of `ConfigStateService` to get a specific configuration property. For that, the property name should be passed to the method as parameter. ```js -// this.config is instance of ConfigStateService +// this.config is an instance of ConfigStateService const currentUser = this.config.getOne("currentUser"); From 7f93fd261e69a0998e896418856e976e784f203b Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Mon, 15 Aug 2022 17:34:53 +0300 Subject: [PATCH 023/106] Add Custom Component Feature to ExtensibleForm. --- .../account/src/lib/account-routing.module.ts | 4 +- .../account/src/lib/account.module.ts | 13 +++- ...xtensible-personal-settings.component.html | 5 ++ ...xtensible-personal-settings.component.scss | 0 ...nsible-personal-settings.component.spec.ts | 24 +++++++ .../extensible-personal-settings.component.ts | 42 +++++++++++ .../lib/components/hello/hello.component.ts | 15 ++++ .../default-personal-settings-form-props.ts | 15 ++++ .../src/lib/guards/extensions.guard.ts | 42 +++++++++++ .../packages/account/src/lib/guards/index.ts | 1 + .../account/src/lib/models/config-options.ts | 11 +++ .../src/lib/tokens/extensions.token.ts | 17 +++++ .../packages/account/src/lib/tokens/index.ts | 1 + .../extensible-form-prop.component.html | 6 ++ .../extensible-form-prop.component.ts | 71 ++++++++++++------- .../extensible-table.component.ts | 9 +-- .../extensions/src/lib/models/form-props.ts | 2 + .../extensions/src/lib/models/props.ts | 1 + .../src/lib/tokens/extensions.token.ts | 3 + 19 files changed, 250 insertions(+), 32 deletions(-) create mode 100644 npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.html create mode 100644 npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.scss create mode 100644 npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.spec.ts create mode 100644 npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.ts create mode 100644 npm/ng-packs/packages/account/src/lib/components/hello/hello.component.ts create mode 100644 npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts create mode 100644 npm/ng-packs/packages/account/src/lib/guards/extensions.guard.ts create mode 100644 npm/ng-packs/packages/account/src/lib/tokens/extensions.token.ts diff --git a/npm/ng-packs/packages/account/src/lib/account-routing.module.ts b/npm/ng-packs/packages/account/src/lib/account-routing.module.ts index c09dede3cb..e4b18a717b 100644 --- a/npm/ng-packs/packages/account/src/lib/account-routing.module.ts +++ b/npm/ng-packs/packages/account/src/lib/account-routing.module.ts @@ -13,6 +13,8 @@ import { RegisterComponent } from './components/register/register.component'; import { ResetPasswordComponent } from './components/reset-password/reset-password.component'; import { eAccountComponents } from './enums/components'; import { AuthenticationFlowGuard } from './guards/authentication-flow.guard'; +import { AccountExtensionsGuard } from './guards'; + const routes: Routes = [ { path: '', pathMatch: 'full', redirectTo: 'login' }, @@ -68,7 +70,7 @@ const routes: Routes = [ { path: 'manage', component: ReplaceableRouteContainerComponent, - canActivate: [AuthGuard], + canActivate: [AuthGuard, AccountExtensionsGuard], data: { replaceableComponent: { key: eAccountComponents.ManageProfile, diff --git a/npm/ng-packs/packages/account/src/lib/account.module.ts b/npm/ng-packs/packages/account/src/lib/account.module.ts index bfa37d4bfa..26f71ef150 100644 --- a/npm/ng-packs/packages/account/src/lib/account.module.ts +++ b/npm/ng-packs/packages/account/src/lib/account.module.ts @@ -15,6 +15,11 @@ import { accountConfigOptionsFactory } from './utils/factory-utils'; import { AuthenticationFlowGuard } from './guards/authentication-flow.guard'; import { ForgotPasswordComponent } from './components/forgot-password/forgot-password.component'; import { ResetPasswordComponent } from './components/reset-password/reset-password.component'; +import { ExtensiblePersonalSettingsComponent } from './components/extensible-personal-settings/extensible-personal-settings.component'; +import { UiExtensionsModule } from '@abp/ng.theme.shared/extensions'; +import { ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS } from './tokens/extensions.token'; +import { AccountExtensionsGuard } from './guards/extensions.guard'; +import { HelloComponent } from './components/hello/hello.component'; const declarations = [ LoginComponent, @@ -27,13 +32,14 @@ const declarations = [ ]; @NgModule({ - declarations: [...declarations], + declarations: [...declarations, ExtensiblePersonalSettingsComponent, HelloComponent], imports: [ CoreModule, AccountRoutingModule, ThemeSharedModule, NgbDropdownModule, NgxValidateCoreModule, + UiExtensionsModule, ], exports: [...declarations], }) @@ -49,6 +55,11 @@ export class AccountModule { useFactory: accountConfigOptionsFactory, deps: [ACCOUNT_CONFIG_OPTIONS], }, + { + provide: ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS, + useValue: options.editFormPropContributors, + }, + AccountExtensionsGuard, ], }; } diff --git a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.html b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.html new file mode 100644 index 0000000000..5b17770996 --- /dev/null +++ b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.html @@ -0,0 +1,5 @@ +

extensible-personal-settings works!

+ +
+ +
diff --git a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.scss b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.spec.ts b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.spec.ts new file mode 100644 index 0000000000..e2a2102e5a --- /dev/null +++ b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.spec.ts @@ -0,0 +1,24 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ExtensiblePersonalSettingsComponent } from './extensible-personal-settings.component'; + +describe('ExtensiblePersonalSettingsComponent', () => { + let component: ExtensiblePersonalSettingsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ExtensiblePersonalSettingsComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ExtensiblePersonalSettingsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.ts b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.ts new file mode 100644 index 0000000000..0b54672cab --- /dev/null +++ b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.ts @@ -0,0 +1,42 @@ +import {Component, Injector, OnInit} from '@angular/core'; +import {EXTENSIONS_IDENTIFIER, FormPropData, generateFormFromProps} from "@abp/ng.theme.shared/extensions"; +import { eAccountComponents } from '../../enums/components'; +import {FormBuilder, FormGroup} from "@angular/forms"; +import {ProfileService} from "@abp/ng.account.core/proxy"; + +@Component({ + selector: 'abp-extensible-personal-settings', + templateUrl: './extensible-personal-settings.component.html', + styleUrls: ['./extensible-personal-settings.component.scss'], + providers:[ + { + provide: EXTENSIONS_IDENTIFIER, + useValue: eAccountComponents.PersonalSettings, + }, + ] +}) +export class ExtensiblePersonalSettingsComponent implements OnInit { + selected = {a: 1};// hacky for triggering 'edit' mode of extensible-form + + form: FormGroup; + + constructor( + private profileService: ProfileService, + protected fb: FormBuilder, + protected injector: Injector, + ) {} + + + buildForm() { + const data = new FormPropData(this.injector, this.selected); + this.form = generateFormFromProps(data); + } + + ngOnInit(): void { + this.buildForm() + } + + save() { + + } +} diff --git a/npm/ng-packs/packages/account/src/lib/components/hello/hello.component.ts b/npm/ng-packs/packages/account/src/lib/components/hello/hello.component.ts new file mode 100644 index 0000000000..2fc59314aa --- /dev/null +++ b/npm/ng-packs/packages/account/src/lib/components/hello/hello.component.ts @@ -0,0 +1,15 @@ +import {Component, Inject } from '@angular/core'; +import {FORM_PROP_DATA_STREAM, FormProp} from "@abp/ng.theme.shared/extensions"; + +@Component({ + selector: 'abp-hello', + template: `

hello works! {{name | abpLocalization}}

`, + styles: [], +}) +export class HelloComponent { + name:string; + constructor(@Inject(FORM_PROP_DATA_STREAM) private propData:FormProp) { + this.name = propData.displayName + } + +} diff --git a/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts b/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts new file mode 100644 index 0000000000..0624e074d3 --- /dev/null +++ b/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts @@ -0,0 +1,15 @@ +import {ePropType, FormProp} from "@abp/ng.theme.shared/extensions"; +import {UpdateProfileDto} from "@abp/ng.account.core/proxy"; +import {Validators} from "@angular/forms"; +import {HelloComponent} from "../components/hello/hello.component"; + +export const DEFAULT_PERSONAL_SETTINGS_UPDATE_FORM_PROPS = FormProp.createMany([ + { + type: ePropType.String, + name: 'userName', + displayName: 'Account::UserName', + id: 'user-name', + validators: () => [Validators.required, Validators.maxLength(256)], + template: HelloComponent + }, +]) diff --git a/npm/ng-packs/packages/account/src/lib/guards/extensions.guard.ts b/npm/ng-packs/packages/account/src/lib/guards/extensions.guard.ts new file mode 100644 index 0000000000..20c4269977 --- /dev/null +++ b/npm/ng-packs/packages/account/src/lib/guards/extensions.guard.ts @@ -0,0 +1,42 @@ +import {Injectable, Injector} from "@angular/core"; +import {CanActivate} from "@angular/router"; +import {Observable} from "rxjs"; +import { + ExtensionsService, + getObjectExtensionEntitiesFromStore, + mapEntitiesToContributors, mergeWithDefaultProps +} from "@abp/ng.theme.shared/extensions"; + import {ConfigStateService} from "@abp/ng.core"; +import {tap, map, mapTo} from "rxjs/operators"; +import {ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS, DEFAULT_ACCOUNT_FORM_PROPS} from '../tokens/extensions.token'; +import { AccountEditFormPropContributors } from '../models/config-options'; +import { eAccountComponents } from '../enums/components'; + +@Injectable() +export class AccountExtensionsGuard implements CanActivate { + constructor(private injector: Injector) {} + + canActivate(): Observable { + const extensions: ExtensionsService = this.injector.get(ExtensionsService); + + const editFormContributors: AccountEditFormPropContributors = + this.injector.get(ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS, null) || {}; + + const configState = this.injector.get(ConfigStateService); + return getObjectExtensionEntitiesFromStore(configState, 'Account').pipe( + map(entities => ({ + [eAccountComponents.PersonalSettings]: entities.PersonalSettings, + })), + mapEntitiesToContributors(configState, 'AbpAccount'), + tap(objectExtensionContributors => { + mergeWithDefaultProps( + extensions.editFormProps, + DEFAULT_ACCOUNT_FORM_PROPS, + objectExtensionContributors.editForm, + editFormContributors, + ); + }), + mapTo(true), + ); + } +} diff --git a/npm/ng-packs/packages/account/src/lib/guards/index.ts b/npm/ng-packs/packages/account/src/lib/guards/index.ts index 382170b2b1..275cd2f8e8 100644 --- a/npm/ng-packs/packages/account/src/lib/guards/index.ts +++ b/npm/ng-packs/packages/account/src/lib/guards/index.ts @@ -1 +1,2 @@ export * from './authentication-flow.guard'; +export * from './extensions.guard'; diff --git a/npm/ng-packs/packages/account/src/lib/models/config-options.ts b/npm/ng-packs/packages/account/src/lib/models/config-options.ts index 898021b04e..f2e603ab32 100644 --- a/npm/ng-packs/packages/account/src/lib/models/config-options.ts +++ b/npm/ng-packs/packages/account/src/lib/models/config-options.ts @@ -1,3 +1,14 @@ +import {eAccountComponents} from "../enums"; +import { EditFormPropContributorCallback } from '@abp/ng.theme.shared/extensions'; +import {UpdateProfileDto} from "@abp/ng.account.core/proxy"; + export interface AccountConfigOptions { redirectUrl?: string; } +export type AccountEditFormPropContributors = Partial<{ + [eAccountComponents.PersonalSettings]: EditFormPropContributorCallback[]; +}>; + +export interface AccountConfigOptions { + editFormPropContributors?: AccountEditFormPropContributors; +} diff --git a/npm/ng-packs/packages/account/src/lib/tokens/extensions.token.ts b/npm/ng-packs/packages/account/src/lib/tokens/extensions.token.ts new file mode 100644 index 0000000000..6d95db8b6d --- /dev/null +++ b/npm/ng-packs/packages/account/src/lib/tokens/extensions.token.ts @@ -0,0 +1,17 @@ +import {eAccountComponents} from "../enums"; +import {DEFAULT_PERSONAL_SETTINGS_UPDATE_FORM_PROPS} from "../defaults/default-personal-settings-form-props"; +import {InjectionToken} from "@angular/core"; +import {EditFormPropContributorCallback} from "@abp/ng.theme.shared/extensions"; +import {UpdateProfileDto} from "@abp/ng.account.core/proxy"; + +export const DEFAULT_ACCOUNT_FORM_PROPS = { + [eAccountComponents.PersonalSettings]: DEFAULT_PERSONAL_SETTINGS_UPDATE_FORM_PROPS, +}; + +export const ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS = new InjectionToken( + 'ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS', +); + +type EditFormPropContributors = Partial<{ + [eAccountComponents.PersonalSettings]: EditFormPropContributorCallback[]; +}>; diff --git a/npm/ng-packs/packages/account/src/lib/tokens/index.ts b/npm/ng-packs/packages/account/src/lib/tokens/index.ts index 0a88318130..4381d1bc77 100644 --- a/npm/ng-packs/packages/account/src/lib/tokens/index.ts +++ b/npm/ng-packs/packages/account/src/lib/tokens/index.ts @@ -1 +1,2 @@ export * from './config-options.token'; +export * from './extensions.token'; diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html index 4367bd098a..67b0022be8 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html @@ -3,6 +3,12 @@ *abpPermission="prop.permission; runChangeDetection: false" [ngSwitch]="getComponent(prop)" > + + + + + + ; + public injectorForCustomComponent: Injector + asterisk = ''; options$: Observable[]> = of([]); @@ -62,15 +65,16 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { readonly!: boolean; - disabledFn = (data:PropData) => false; - - get disabled() { - return this.disabledFn(this.data) - } + typeaheadModel: any; private readonly form: FormGroup; - typeaheadModel: any; + disabledFn = (data: PropData) => false; + + get disabled() { + return this.disabledFn(this.data) + } + setTypeaheadValue(selectedOption: ABP.Option) { this.typeaheadModel = selectedOption || { key: null, value: null }; @@ -108,12 +112,13 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { public readonly track: TrackByService, protected configState: ConfigStateService, groupDirective: FormGroupDirective, + private injector: Injector ) { this.form = groupDirective.form; } private getTypeaheadControls() { - const { name } = this.prop; + const {name} = this.prop; const extraPropName = `${EXTRA_PROPERTIES_KEY}.${name}`; const keyControl = this.form.get(addTypeaheadTextSuffix(extraPropName)) || @@ -133,6 +138,9 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { } getComponent(prop: FormProp): string { + if (prop.template) { + return 'template' + } switch (prop.type) { case ePropType.Boolean: return 'checkbox'; @@ -173,13 +181,24 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { } } - ngOnChanges({ prop }: SimpleChanges) { - const currentProp = prop?.currentValue; - const { options, readonly, disabled, validators } = currentProp || {}; + ngOnChanges({prop}: SimpleChanges) { + const currentProp = prop?.currentValue as FormProp; + const {options, readonly, disabled, validators, template} = currentProp || {}; + if (template) { + this.injectorForCustomComponent = Injector.create({ + providers: [ + { + provide: FORM_PROP_DATA_STREAM, + useValue: currentProp + } + ], + parent: this.injector, + }); + } if (options) this.options$ = options(this.data); if (readonly) this.readonly = readonly(this.data); - + if (disabled) { this.disabledFn = disabled; } diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts index 9682188638..d3c58f0c93 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-table/extensible-table.component.ts @@ -158,15 +158,16 @@ export class ExtensibleTableComponent implements OnChanges { value, }; if (prop.value.component) { - const injector = Injector.create( - [ + + const injector = Injector.create({ + providers: [ { provide: PROP_DATA_STREAM, useValue: value, }, ], - this.injector, - ); + parent: this.injector, + }); record[propKey].injector = injector; record[propKey].component = prop.value.component; } diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts index 44b309d0c2..b607e4cb6e 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts @@ -38,6 +38,7 @@ export class FormProp extends Prop { readonly defaultValue: boolean | number | string | Date; readonly options: PropCallback[]>> | undefined; readonly id: string | undefined; + readonly template? : Type constructor(options: FormPropOptions) { super( @@ -47,6 +48,7 @@ export class FormProp extends Prop { options.permission, options.visible, options.isExtra, + options.template ); this.asyncValidators = options.asyncValidators || (_ => []); diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts index 66fc4f2c67..0b26512dbc 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts @@ -33,6 +33,7 @@ export abstract class Prop { public readonly permission: string, public readonly visible: PropPredicate = _ => true, public readonly isExtra = false, + public readonly template? : Type ) { this.displayName = this.displayName || this.name; } diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts index d2cbbe87bd..28f26317d8 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts @@ -3,6 +3,7 @@ import { ActionCallback, ReadonlyActionData as ActionData } from '../models/acti import { ExtensionsService } from '../services/extensions.service'; import { Observable } from 'rxjs'; import { ePropType } from '../enums/props.enum'; + import {FormProp} from "../models/form-props"; export const EXTENSIONS_IDENTIFIER = new InjectionToken('EXTENSIONS_IDENTIFIER'); export type ActionKeys = Extract<'entityActions' | 'toolbarActions', keyof ExtensionsService>; @@ -24,3 +25,5 @@ export const ENTITY_PROP_TYPE_CLASSES = new InjectionToken( factory: () => ({} as EntityPropTypeClass), }, ); + +export const FORM_PROP_DATA_STREAM = new InjectionToken('FORM_PROP_DATA_STREAM'); From 4a421e0da7dec84da25470473ad050ff840104db Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Tue, 16 Aug 2022 09:05:14 +0300 Subject: [PATCH 024/106] Move extensible form to personal settings component --- .../account/src/lib/account.module.ts | 8 +- ...xtensible-personal-settings.component.html | 5 - ...xtensible-personal-settings.component.scss | 0 ...nsible-personal-settings.component.spec.ts | 24 -- .../extensible-personal-settings.component.ts | 42 --- .../half-row/half-row.component.ts | 33 +++ .../name-surname/name-surname.component.ts | 30 +++ .../personal-settings.component.html | 50 +--- .../personal-settings.component.ts | 47 ++-- .../default-personal-settings-form-props.ts | 40 ++- .../extensible-form-prop.component.html | 241 +++++++++--------- .../extensible-form-prop.component.ts | 17 +- 12 files changed, 267 insertions(+), 270 deletions(-) delete mode 100644 npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.html delete mode 100644 npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.scss delete mode 100644 npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.spec.ts delete mode 100644 npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.ts create mode 100644 npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts create mode 100644 npm/ng-packs/packages/account/src/lib/components/personal-settings/name-surname/name-surname.component.ts diff --git a/npm/ng-packs/packages/account/src/lib/account.module.ts b/npm/ng-packs/packages/account/src/lib/account.module.ts index 26f71ef150..d8c88055d9 100644 --- a/npm/ng-packs/packages/account/src/lib/account.module.ts +++ b/npm/ng-packs/packages/account/src/lib/account.module.ts @@ -15,11 +15,11 @@ import { accountConfigOptionsFactory } from './utils/factory-utils'; import { AuthenticationFlowGuard } from './guards/authentication-flow.guard'; import { ForgotPasswordComponent } from './components/forgot-password/forgot-password.component'; import { ResetPasswordComponent } from './components/reset-password/reset-password.component'; -import { ExtensiblePersonalSettingsComponent } from './components/extensible-personal-settings/extensible-personal-settings.component'; import { UiExtensionsModule } from '@abp/ng.theme.shared/extensions'; import { ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS } from './tokens/extensions.token'; import { AccountExtensionsGuard } from './guards/extensions.guard'; -import { HelloComponent } from './components/hello/hello.component'; +import { HalfRowComponent } from './components/personal-settings/half-row/half-row.component'; +import { NameSurnameComponent } from './components/personal-settings/name-surname/name-surname.component'; const declarations = [ LoginComponent, @@ -29,10 +29,12 @@ const declarations = [ PersonalSettingsComponent, ForgotPasswordComponent, ResetPasswordComponent, + HalfRowComponent, + NameSurnameComponent ]; @NgModule({ - declarations: [...declarations, ExtensiblePersonalSettingsComponent, HelloComponent], + declarations: [...declarations], imports: [ CoreModule, AccountRoutingModule, diff --git a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.html b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.html deleted file mode 100644 index 5b17770996..0000000000 --- a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.html +++ /dev/null @@ -1,5 +0,0 @@ -

extensible-personal-settings works!

- -
- -
diff --git a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.scss b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.scss deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.spec.ts b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.spec.ts deleted file mode 100644 index e2a2102e5a..0000000000 --- a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ExtensiblePersonalSettingsComponent } from './extensible-personal-settings.component'; - -describe('ExtensiblePersonalSettingsComponent', () => { - let component: ExtensiblePersonalSettingsComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ExtensiblePersonalSettingsComponent], - }).compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(ExtensiblePersonalSettingsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.ts b/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.ts deleted file mode 100644 index 0b54672cab..0000000000 --- a/npm/ng-packs/packages/account/src/lib/components/extensible-personal-settings/extensible-personal-settings.component.ts +++ /dev/null @@ -1,42 +0,0 @@ -import {Component, Injector, OnInit} from '@angular/core'; -import {EXTENSIONS_IDENTIFIER, FormPropData, generateFormFromProps} from "@abp/ng.theme.shared/extensions"; -import { eAccountComponents } from '../../enums/components'; -import {FormBuilder, FormGroup} from "@angular/forms"; -import {ProfileService} from "@abp/ng.account.core/proxy"; - -@Component({ - selector: 'abp-extensible-personal-settings', - templateUrl: './extensible-personal-settings.component.html', - styleUrls: ['./extensible-personal-settings.component.scss'], - providers:[ - { - provide: EXTENSIONS_IDENTIFIER, - useValue: eAccountComponents.PersonalSettings, - }, - ] -}) -export class ExtensiblePersonalSettingsComponent implements OnInit { - selected = {a: 1};// hacky for triggering 'edit' mode of extensible-form - - form: FormGroup; - - constructor( - private profileService: ProfileService, - protected fb: FormBuilder, - protected injector: Injector, - ) {} - - - buildForm() { - const data = new FormPropData(this.injector, this.selected); - this.form = generateFormFromProps(data); - } - - ngOnInit(): void { - this.buildForm() - } - - save() { - - } -} diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts b/npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts new file mode 100644 index 0000000000..76c741459b --- /dev/null +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts @@ -0,0 +1,33 @@ +import {Component, Inject} from '@angular/core'; +import {FORM_PROP_DATA_STREAM, FormProp} from "@abp/ng.theme.shared/extensions"; +import {ControlContainer, FormGroup, FormGroupDirective} from "@angular/forms"; + +@Component({ + selector: 'abp-half-row', + template: ` +
+
+ + +
+
`, + styles: [], + viewProviders: [{ provide: ControlContainer, useExisting: FormGroupDirective }] + +}) +export class HalfRowComponent { + public displayName: string; + public name: string; + public id: string; + public formGroup: FormGroup + + constructor(@Inject(FORM_PROP_DATA_STREAM) private propData: FormProp) { + this.displayName = propData.displayName + this.name = propData.name + this.id = propData.id + } +} diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/name-surname/name-surname.component.ts b/npm/ng-packs/packages/account/src/lib/components/personal-settings/name-surname/name-surname.component.ts new file mode 100644 index 0000000000..7701f4567f --- /dev/null +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/name-surname/name-surname.component.ts @@ -0,0 +1,30 @@ +import { Component } from '@angular/core'; +import {ControlContainer, FormGroupDirective} from "@angular/forms"; + +@Component({ + selector: 'abp-name-surname', + template: `
+
+
+ +
+
+
+
+ +
+
+
`, + styles: [], + viewProviders: [{ provide: ControlContainer, useExisting: FormGroupDirective }] + +}) +export class NameSurnameComponent { + constructor() {} +} diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html index 0b70ad41e8..42a323e5ca 100644 --- a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html @@ -1,49 +1,7 @@ -
-
- * -
-
-
-
- -
-
-
-
- -
-
-
-
- * -
-
- -
+

Thor

+ + + ([ { type: ePropType.String, name: 'userName', - displayName: 'Account::UserName', - id: 'user-name', - validators: () => [Validators.required, Validators.maxLength(256)], - template: HelloComponent + displayName: 'AbpIdentity::DisplayName:UserName', + id: 'username', + validators: () => [required,maxLength(256)], + }, + { + type: ePropType.String, + name: 'name', + displayName: 'AbpIdentity::DisplayName:Name', + id: 'name', + validators: () => [maxLength(64),required], + template:NameSurnameComponent + }, + { + type: ePropType.String, + name: 'surname', + displayName: 'AbpIdentity::DisplayName:Surname', + id: 'surname', + validators: () => [maxLength(64),required], + visible:() => false + }, + { + type: ePropType.String, + name: 'email', + displayName: 'AbpIdentity::DisplayName:Email', + id: 'email-address', + validators: () => [required, email, maxLength(256)], + }, + { + type: ePropType.String, + name: 'phoneNumber', + displayName: 'AbpIdentity::DisplayName:PhoneNumber', + id: 'phone-number', + validators: () => [maxLength(16)], }, ]) diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html index 67b0022be8..239882a498 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html @@ -1,148 +1,153 @@ -
+ - + - - - - - - - - +
- -
+ + - -
-
+ - - - - + + + - - - + +
+ + + + + - + + + - - -
- + + + + + + +
+ + +
+
+ + + + - -
-
+ - - - - + + + + - - - - + + + + - - - - + + + + +
- - - - - + {{ prop.displayName | abpLocalization }} {{ asterisk }} diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts index 49257f34c9..efa894cf55 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts @@ -77,8 +77,8 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { setTypeaheadValue(selectedOption: ABP.Option) { - this.typeaheadModel = selectedOption || { key: null, value: null }; - const { key, value } = this.typeaheadModel; + this.typeaheadModel = selectedOption || {key: null, value: null}; + const {key, value} = this.typeaheadModel; const [keyControl, valueControl] = this.getTypeaheadControls(); if (valueControl?.value && !value) valueControl.markAsDirty(); keyControl?.setValue(key); @@ -88,10 +88,10 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { search = (text$: Observable) => text$ ? text$.pipe( - debounceTime(300), - distinctUntilChanged(), - switchMap(text => this.prop.options(this.data, text)), - ) + debounceTime(300), + distinctUntilChanged(), + switchMap(text => this.prop.options(this.data, text)), + ) : of([]); typeaheadFormatter = (option: ABP.Option) => option.key; @@ -190,7 +190,8 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { { provide: FORM_PROP_DATA_STREAM, useValue: currentProp - } + }, + ], parent: this.injector, }); @@ -209,7 +210,7 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { const [keyControl, valueControl] = this.getTypeaheadControls(); if (keyControl && valueControl) - this.typeaheadModel = { key: keyControl.value, value: valueControl.value }; + this.typeaheadModel = {key: keyControl.value, value: valueControl.value}; } } From 30a2120cdbcba2741848306cf71a714888ec4b4b Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Tue, 16 Aug 2022 14:48:08 +0300 Subject: [PATCH 025/106] Implement update profile with Extensible-form --- .../account/src/lib/account.module.ts | 3 -- .../half-row/half-row.component.ts | 5 ++-- .../name-surname/name-surname.component.ts | 30 ------------------- .../personal-settings.component.html | 1 - .../default-personal-settings-form-props.ts | 12 ++++---- .../extensible-form-prop.component.html | 1 - .../extensible-form-prop.component.ts | 2 +- .../extensible-form.component.html | 4 +-- .../extensible-form.component.ts | 5 +++- .../extensions/src/lib/models/form-props.ts | 4 ++- .../extensions/src/lib/models/props.ts | 3 +- 11 files changed, 21 insertions(+), 49 deletions(-) delete mode 100644 npm/ng-packs/packages/account/src/lib/components/personal-settings/name-surname/name-surname.component.ts diff --git a/npm/ng-packs/packages/account/src/lib/account.module.ts b/npm/ng-packs/packages/account/src/lib/account.module.ts index d8c88055d9..3929963665 100644 --- a/npm/ng-packs/packages/account/src/lib/account.module.ts +++ b/npm/ng-packs/packages/account/src/lib/account.module.ts @@ -19,8 +19,6 @@ import { UiExtensionsModule } from '@abp/ng.theme.shared/extensions'; import { ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS } from './tokens/extensions.token'; import { AccountExtensionsGuard } from './guards/extensions.guard'; import { HalfRowComponent } from './components/personal-settings/half-row/half-row.component'; -import { NameSurnameComponent } from './components/personal-settings/name-surname/name-surname.component'; - const declarations = [ LoginComponent, RegisterComponent, @@ -30,7 +28,6 @@ const declarations = [ ForgotPasswordComponent, ResetPasswordComponent, HalfRowComponent, - NameSurnameComponent ]; @NgModule({ diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts b/npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts index 76c741459b..a0f0ead029 100644 --- a/npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts @@ -5,12 +5,11 @@ import {ControlContainer, FormGroup, FormGroupDirective} from "@angular/forms"; @Component({ selector: 'abp-half-row', template: ` -
+
-
diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/name-surname/name-surname.component.ts b/npm/ng-packs/packages/account/src/lib/components/personal-settings/name-surname/name-surname.component.ts deleted file mode 100644 index 7701f4567f..0000000000 --- a/npm/ng-packs/packages/account/src/lib/components/personal-settings/name-surname/name-surname.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { Component } from '@angular/core'; -import {ControlContainer, FormGroupDirective} from "@angular/forms"; - -@Component({ - selector: 'abp-name-surname', - template: `
-
-
- -
-
-
-
- -
-
-
`, - styles: [], - viewProviders: [{ provide: ControlContainer, useExisting: FormGroupDirective }] - -}) -export class NameSurnameComponent { - constructor() {} -} diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html index 42a323e5ca..86dd3272b3 100644 --- a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings.component.html @@ -1,4 +1,3 @@ -

Thor

diff --git a/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts b/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts index 6a1038e64a..d99401ecf2 100644 --- a/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts +++ b/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts @@ -1,7 +1,7 @@ import {ePropType, FormProp} from "@abp/ng.theme.shared/extensions"; import {UpdateProfileDto} from "@abp/ng.account.core/proxy"; import {Validators} from "@angular/forms"; - import {NameSurnameComponent} from "../components/personal-settings/name-surname/name-surname.component"; + import {HalfRowComponent} from "../components/personal-settings/half-row/half-row.component"; const { maxLength, required, email } = Validators; export const DEFAULT_PERSONAL_SETTINGS_UPDATE_FORM_PROPS = FormProp.createMany([ @@ -17,16 +17,18 @@ export const DEFAULT_PERSONAL_SETTINGS_UPDATE_FORM_PROPS = FormProp.createMany [maxLength(64),required], - template:NameSurnameComponent + validators: () => [maxLength(64)], + template:HalfRowComponent, + className:"d-inline-block w-50" }, { type: ePropType.String, name: 'surname', displayName: 'AbpIdentity::DisplayName:Surname', id: 'surname', - validators: () => [maxLength(64),required], - visible:() => false + validators: () => [maxLength(64)], + className:"d-inline-block w-50 ps-4", + template:HalfRowComponent }, { type: ePropType.String, diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html index 239882a498..dd125f5afc 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.html @@ -3,7 +3,6 @@ diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts index efa894cf55..a7a7d22708 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts @@ -191,7 +191,7 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { provide: FORM_PROP_DATA_STREAM, useValue: currentProp }, - + { provide: ControlContainer, useExisting: FormGroupDirective } ], parent: this.injector, }); diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form.component.html b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form.component.html index 259538820b..69ad86da5c 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form.component.html +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form.component.html @@ -6,11 +6,11 @@ [formGroupName]="extraPropertiesKey" *ngIf="extraProperties.controls[prop.name]; else tempDefault" > - + - { @Inject(EXTENSIONS_IDENTIFIER) private identifier: string, ) {} } + + +export const ExtensibleFormViewProvider = { provide: ControlContainer, useExisting: FormGroupDirective } diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts index b607e4cb6e..4e71c70e0f 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/form-props.ts @@ -39,6 +39,7 @@ export class FormProp extends Prop { readonly options: PropCallback[]>> | undefined; readonly id: string | undefined; readonly template? : Type + readonly className?:string; constructor(options: FormPropOptions) { super( @@ -48,7 +49,8 @@ export class FormProp extends Prop { options.permission, options.visible, options.isExtra, - options.template + options.template, + options.className ); this.asyncValidators = options.asyncValidators || (_ => []); diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts index 0b26512dbc..e8bb158cc9 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/models/props.ts @@ -33,7 +33,8 @@ export abstract class Prop { public readonly permission: string, public readonly visible: PropPredicate = _ => true, public readonly isExtra = false, - public readonly template? : Type + public readonly template? : Type, + public readonly className?:string ) { this.displayName = this.displayName || this.name; } From db5a3fb4bf587259244023fd42aa6cf6ff8db3f1 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Tue, 16 Aug 2022 15:43:36 +0300 Subject: [PATCH 026/106] Change HalfRowComponent name and export it --- .../account/src/lib/account.module.ts | 47 ++++++++++--------- .../account/src/lib/components/index.ts | 1 + ...> personal-settings-half-row.component.ts} | 4 +- .../default-personal-settings-form-props.ts | 6 +-- 4 files changed, 30 insertions(+), 28 deletions(-) rename npm/ng-packs/packages/account/src/lib/components/personal-settings/{half-row/half-row.component.ts => personal-settings-half-row.component.ts} (91%) diff --git a/npm/ng-packs/packages/account/src/lib/account.module.ts b/npm/ng-packs/packages/account/src/lib/account.module.ts index 3929963665..74310ce1bd 100644 --- a/npm/ng-packs/packages/account/src/lib/account.module.ts +++ b/npm/ng-packs/packages/account/src/lib/account.module.ts @@ -1,24 +1,25 @@ -import { CoreModule, LazyModuleFactory } from '@abp/ng.core'; -import { ThemeSharedModule } from '@abp/ng.theme.shared'; -import { ModuleWithProviders, NgModule, NgModuleFactory } from '@angular/core'; -import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; -import { NgxValidateCoreModule } from '@ngx-validate/core'; -import { AccountRoutingModule } from './account-routing.module'; -import { ChangePasswordComponent } from './components/change-password/change-password.component'; -import { LoginComponent } from './components/login/login.component'; -import { ManageProfileComponent } from './components/manage-profile/manage-profile.component'; -import { PersonalSettingsComponent } from './components/personal-settings/personal-settings.component'; -import { RegisterComponent } from './components/register/register.component'; -import { AccountConfigOptions } from './models/config-options'; -import { ACCOUNT_CONFIG_OPTIONS } from './tokens/config-options.token'; -import { accountConfigOptionsFactory } from './utils/factory-utils'; -import { AuthenticationFlowGuard } from './guards/authentication-flow.guard'; -import { ForgotPasswordComponent } from './components/forgot-password/forgot-password.component'; -import { ResetPasswordComponent } from './components/reset-password/reset-password.component'; -import { UiExtensionsModule } from '@abp/ng.theme.shared/extensions'; -import { ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS } from './tokens/extensions.token'; -import { AccountExtensionsGuard } from './guards/extensions.guard'; -import { HalfRowComponent } from './components/personal-settings/half-row/half-row.component'; +import {CoreModule, LazyModuleFactory} from '@abp/ng.core'; +import {ThemeSharedModule} from '@abp/ng.theme.shared'; +import {ModuleWithProviders, NgModule, NgModuleFactory} from '@angular/core'; +import {NgbDropdownModule} from '@ng-bootstrap/ng-bootstrap'; +import {NgxValidateCoreModule} from '@ngx-validate/core'; +import {AccountRoutingModule} from './account-routing.module'; +import {ChangePasswordComponent} from './components/change-password/change-password.component'; +import {LoginComponent} from './components/login/login.component'; +import {ManageProfileComponent} from './components/manage-profile/manage-profile.component'; +import {PersonalSettingsComponent} from './components/personal-settings/personal-settings.component'; +import {RegisterComponent} from './components/register/register.component'; +import {AccountConfigOptions} from './models/config-options'; +import {ACCOUNT_CONFIG_OPTIONS} from './tokens/config-options.token'; +import {accountConfigOptionsFactory} from './utils/factory-utils'; +import {AuthenticationFlowGuard} from './guards/authentication-flow.guard'; +import {ForgotPasswordComponent} from './components/forgot-password/forgot-password.component'; +import {ResetPasswordComponent} from './components/reset-password/reset-password.component'; +import {UiExtensionsModule} from '@abp/ng.theme.shared/extensions'; +import {ACCOUNT_EDIT_FORM_PROP_CONTRIBUTORS} from './tokens/extensions.token'; +import {AccountExtensionsGuard} from './guards/extensions.guard'; +import {PersonalSettingsHalfRowComponent} from './components/personal-settings/personal-settings-half-row.component'; + const declarations = [ LoginComponent, RegisterComponent, @@ -27,7 +28,7 @@ const declarations = [ PersonalSettingsComponent, ForgotPasswordComponent, ResetPasswordComponent, - HalfRowComponent, + PersonalSettingsHalfRowComponent, ]; @NgModule({ @@ -48,7 +49,7 @@ export class AccountModule { ngModule: AccountModule, providers: [ AuthenticationFlowGuard, - { provide: ACCOUNT_CONFIG_OPTIONS, useValue: options }, + {provide: ACCOUNT_CONFIG_OPTIONS, useValue: options}, { provide: 'ACCOUNT_OPTIONS', useFactory: accountConfigOptionsFactory, diff --git a/npm/ng-packs/packages/account/src/lib/components/index.ts b/npm/ng-packs/packages/account/src/lib/components/index.ts index 098ee8a202..d74263b052 100644 --- a/npm/ng-packs/packages/account/src/lib/components/index.ts +++ b/npm/ng-packs/packages/account/src/lib/components/index.ts @@ -4,4 +4,5 @@ export * from './login/login.component'; export * from './manage-profile/manage-profile.component'; export * from './register/register.component'; export * from './personal-settings/personal-settings.component'; +export * from './personal-settings/personal-settings-half-row.component'; export * from './reset-password/reset-password.component'; diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts similarity index 91% rename from npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts rename to npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts index a0f0ead029..a1086a24a2 100644 --- a/npm/ng-packs/packages/account/src/lib/components/personal-settings/half-row/half-row.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts @@ -3,7 +3,7 @@ import {FORM_PROP_DATA_STREAM, FormProp} from "@abp/ng.theme.shared/extensions"; import {ControlContainer, FormGroup, FormGroupDirective} from "@angular/forms"; @Component({ - selector: 'abp-half-row', + selector: 'abp-personal-settings-half-row', template: `
@@ -18,7 +18,7 @@ import {ControlContainer, FormGroup, FormGroupDirective} from "@angular/forms"; viewProviders: [{ provide: ControlContainer, useExisting: FormGroupDirective }] }) -export class HalfRowComponent { +export class PersonalSettingsHalfRowComponent { public displayName: string; public name: string; public id: string; diff --git a/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts b/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts index d99401ecf2..0e9e06f020 100644 --- a/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts +++ b/npm/ng-packs/packages/account/src/lib/defaults/default-personal-settings-form-props.ts @@ -1,7 +1,7 @@ import {ePropType, FormProp} from "@abp/ng.theme.shared/extensions"; import {UpdateProfileDto} from "@abp/ng.account.core/proxy"; import {Validators} from "@angular/forms"; - import {HalfRowComponent} from "../components/personal-settings/half-row/half-row.component"; + import {PersonalSettingsHalfRowComponent} from "../components/personal-settings/personal-settings-half-row.component"; const { maxLength, required, email } = Validators; export const DEFAULT_PERSONAL_SETTINGS_UPDATE_FORM_PROPS = FormProp.createMany([ @@ -18,7 +18,7 @@ export const DEFAULT_PERSONAL_SETTINGS_UPDATE_FORM_PROPS = FormProp.createMany [maxLength(64)], - template:HalfRowComponent, + template:PersonalSettingsHalfRowComponent, className:"d-inline-block w-50" }, { @@ -28,7 +28,7 @@ export const DEFAULT_PERSONAL_SETTINGS_UPDATE_FORM_PROPS = FormProp.createMany [maxLength(64)], className:"d-inline-block w-50 ps-4", - template:HalfRowComponent + template:PersonalSettingsHalfRowComponent }, { type: ePropType.String, From 9f2ee34ae946845deead42d0ffb254e3bccd6cd7 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Tue, 16 Aug 2022 17:53:40 +0300 Subject: [PATCH 027/106] Add EXTENSIBLE_FORM_VIEW_PROVIDER Token --- .../personal-settings-half-row.component.ts | 7 +++---- .../extensible-form/extensible-form.component.ts | 1 - .../src/lib/tokens/extensible-form-view-provider.token.ts | 3 +++ .../packages/theme-shared/extensions/src/public-api.ts | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensible-form-view-provider.token.ts diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts index a1086a24a2..8629433e02 100644 --- a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts @@ -1,6 +1,6 @@ import {Component, Inject} from '@angular/core'; -import {FORM_PROP_DATA_STREAM, FormProp} from "@abp/ng.theme.shared/extensions"; -import {ControlContainer, FormGroup, FormGroupDirective} from "@angular/forms"; +import {FORM_PROP_DATA_STREAM, FormProp, EXTENSIBLE_FORM_VIEW_PROVIDER} from "@abp/ng.theme.shared/extensions"; +import {FormGroup} from "@angular/forms"; @Component({ selector: 'abp-personal-settings-half-row', @@ -15,8 +15,7 @@ import {ControlContainer, FormGroup, FormGroupDirective} from "@angular/forms";
`, styles: [], - viewProviders: [{ provide: ControlContainer, useExisting: FormGroupDirective }] - + viewProviders: [EXTENSIBLE_FORM_VIEW_PROVIDER] }) export class PersonalSettingsHalfRowComponent { public displayName: string; diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form.component.ts index 83d17b9f0b..2086e3c818 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form.component.ts @@ -64,4 +64,3 @@ export class ExtensibleFormComponent { } -export const ExtensibleFormViewProvider = { provide: ControlContainer, useExisting: FormGroupDirective } diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensible-form-view-provider.token.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensible-form-view-provider.token.ts new file mode 100644 index 0000000000..9db2949731 --- /dev/null +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensible-form-view-provider.token.ts @@ -0,0 +1,3 @@ +import { ControlContainer, FormGroupDirective } from "@angular/forms"; + +export const EXTENSIBLE_FORM_VIEW_PROVIDER = { provide: ControlContainer, useExisting: FormGroupDirective } diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/public-api.ts b/npm/ng-packs/packages/theme-shared/extensions/src/public-api.ts index b19f8eb0d9..f786eb4ac8 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/public-api.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/public-api.ts @@ -64,6 +64,7 @@ export { export * from './lib/pipes/create-injector.pipe'; export * from './lib/services/extensions.service'; export * from './lib/tokens/extensions.token'; +export * from './lib/tokens/extensible-form-view-provider.token'; export * from './lib/ui-extensions.module'; export * from './lib/utils/actions.util'; export * from './lib/utils/form-props.util'; From dde4e9df46997261beadf1f61362d5806a332ec9 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Wed, 17 Aug 2022 17:22:30 +0300 Subject: [PATCH 028/106] add data record as token on Extensible-form-prop --- .../extensible-form-prop.component.ts | 12 ++++++++---- .../extensions/src/lib/tokens/extensions.token.ts | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts index a7a7d22708..7fe8b4fb37 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts @@ -1,3 +1,4 @@ +import { FORM_PROP, FORM_PROP_DATA } from './../../tokens/extensions.token'; import {ABP, AbpValidators, ConfigStateService, TrackByService} from '@abp/ng.core'; import { AfterViewInit, @@ -30,8 +31,7 @@ import {FormProp} from '../../models/form-props'; import {PropData} from '../../models/props'; import {selfFactory} from '../../utils/factory.util'; import {addTypeaheadTextSuffix} from '../../utils/typeahead.util'; -import {FORM_PROP_DATA_STREAM} from "../../tokens/extensions.token"; - + @Component({ selector: 'abp-extensible-form-prop', templateUrl: './extensible-form-prop.component.html', @@ -181,16 +181,20 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { } } - ngOnChanges({prop}: SimpleChanges) { + ngOnChanges({prop,data}: SimpleChanges) { const currentProp = prop?.currentValue as FormProp; const {options, readonly, disabled, validators, template} = currentProp || {}; if (template) { this.injectorForCustomComponent = Injector.create({ providers: [ { - provide: FORM_PROP_DATA_STREAM, + provide: FORM_PROP, useValue: currentProp }, + { + provide: FORM_PROP_DATA, + useValue: (data?.currentValue as PropData)?.record + }, { provide: ControlContainer, useExisting: FormGroupDirective } ], parent: this.injector, diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts index 28f26317d8..0a58566fcf 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/tokens/extensions.token.ts @@ -4,6 +4,7 @@ import { ExtensionsService } from '../services/extensions.service'; import { Observable } from 'rxjs'; import { ePropType } from '../enums/props.enum'; import {FormProp} from "../models/form-props"; +import { PropData } from '../models/props'; export const EXTENSIONS_IDENTIFIER = new InjectionToken('EXTENSIONS_IDENTIFIER'); export type ActionKeys = Extract<'entityActions' | 'toolbarActions', keyof ExtensionsService>; @@ -26,4 +27,5 @@ export const ENTITY_PROP_TYPE_CLASSES = new InjectionToken( }, ); -export const FORM_PROP_DATA_STREAM = new InjectionToken('FORM_PROP_DATA_STREAM'); +export const EXTENSIONS_FORM_PROP = new InjectionToken('EXTENSIONS_FORM_PROP'); +export const EXTENSIONS_FORM_PROP_DATA = new InjectionToken('EXTENSIONS_FORM_PROP_DATA'); From eb0405bc76e985dcae9bec5746fff718a1b20408 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Fri, 19 Aug 2022 15:17:39 +0300 Subject: [PATCH 029/106] Add PropData on ExtensibleForm Template --- .../personal-settings-half-row.component.ts | 4 ++-- .../extensible-form/extensible-form-prop.component.ts | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts index 8629433e02..c0069ecd9e 100644 --- a/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts +++ b/npm/ng-packs/packages/account/src/lib/components/personal-settings/personal-settings-half-row.component.ts @@ -1,5 +1,5 @@ import {Component, Inject} from '@angular/core'; -import {FORM_PROP_DATA_STREAM, FormProp, EXTENSIBLE_FORM_VIEW_PROVIDER} from "@abp/ng.theme.shared/extensions"; +import {EXTENSIONS_FORM_PROP, FormProp, EXTENSIBLE_FORM_VIEW_PROVIDER} from "@abp/ng.theme.shared/extensions"; import {FormGroup} from "@angular/forms"; @Component({ @@ -23,7 +23,7 @@ export class PersonalSettingsHalfRowComponent { public id: string; public formGroup: FormGroup - constructor(@Inject(FORM_PROP_DATA_STREAM) private propData: FormProp) { + constructor(@Inject(EXTENSIONS_FORM_PROP) private propData: FormProp) { this.displayName = propData.displayName this.name = propData.name this.id = propData.id diff --git a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts index 7fe8b4fb37..e9aa694d1f 100644 --- a/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts +++ b/npm/ng-packs/packages/theme-shared/extensions/src/lib/components/extensible-form/extensible-form-prop.component.ts @@ -1,4 +1,4 @@ -import { FORM_PROP, FORM_PROP_DATA } from './../../tokens/extensions.token'; +import { EXTENSIONS_FORM_PROP_DATA, EXTENSIONS_FORM_PROP } from './../../tokens/extensions.token'; import {ABP, AbpValidators, ConfigStateService, TrackByService} from '@abp/ng.core'; import { AfterViewInit, @@ -31,7 +31,7 @@ import {FormProp} from '../../models/form-props'; import {PropData} from '../../models/props'; import {selfFactory} from '../../utils/factory.util'; import {addTypeaheadTextSuffix} from '../../utils/typeahead.util'; - + @Component({ selector: 'abp-extensible-form-prop', templateUrl: './extensible-form-prop.component.html', @@ -188,12 +188,12 @@ export class ExtensibleFormPropComponent implements OnChanges, AfterViewInit { this.injectorForCustomComponent = Injector.create({ providers: [ { - provide: FORM_PROP, + provide: EXTENSIONS_FORM_PROP, useValue: currentProp }, { - provide: FORM_PROP_DATA, - useValue: (data?.currentValue as PropData)?.record + provide: EXTENSIONS_FORM_PROP_DATA, + useValue: (data?.currentValue as PropData)?.record }, { provide: ControlContainer, useExisting: FormGroupDirective } ], From 8cc3ece256a775bee78c86979a46b20cc66e160a Mon Sep 17 00:00:00 2001 From: Salih Date: Fri, 19 Aug 2022 15:31:32 +0300 Subject: [PATCH 030/106] Added project column --- .../Volo/Docs/Admin/Documents/DocumentDto.cs | 2 + .../DocsAdminApplicationAutoMapperProfile.cs | 3 +- .../Pages/Docs/Admin/Documents/Index.cshtml | 1 + .../Pages/Docs/Admin/Documents/index.js | 4 ++ .../Docs/Documents/DocumentWithoutContent.cs | 2 + .../Documents/EFCoreDocumentRepository.cs | 45 +++++++++--------- .../Docs/Documents/MongoDocumentRepository.cs | 47 ++++++++++--------- 7 files changed, 59 insertions(+), 45 deletions(-) diff --git a/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/DocumentDto.cs b/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/DocumentDto.cs index c415efa860..b574870fd8 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/DocumentDto.cs +++ b/modules/docs/src/Volo.Docs.Admin.Application.Contracts/Volo/Docs/Admin/Documents/DocumentDto.cs @@ -8,6 +8,8 @@ namespace Volo.Docs.Admin.Documents public class DocumentDto : EntityDto { public virtual Guid ProjectId { get; set; } + + public virtual string ProjectName { get; set; } public virtual string Name { get; set; } diff --git a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationAutoMapperProfile.cs b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationAutoMapperProfile.cs index 86e6d46e0c..eaeb59cabb 100644 --- a/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationAutoMapperProfile.cs +++ b/modules/docs/src/Volo.Docs.Admin.Application/Volo/Docs/Admin/DocsAdminApplicationAutoMapperProfile.cs @@ -1,4 +1,5 @@ using AutoMapper; +using Volo.Abp.AutoMapper; using Volo.Docs.Admin.Documents; using Volo.Docs.Admin.Projects; using Volo.Docs.Documents; @@ -11,7 +12,7 @@ namespace Volo.Docs.Admin public DocsAdminApplicationAutoMapperProfile() { CreateMap(); - CreateMap(); + CreateMap().Ignore(x => x.ProjectName); CreateMap(); } } diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml index 738327def9..776d504395 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml +++ b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml @@ -183,6 +183,7 @@ @L["Actions"] + @L["ProjectName"] @L["Name"] @L["Version"] @L["LanguageCode"] diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js index 5f4dc9b8d7..d85676e3f3 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js +++ b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/index.js @@ -79,6 +79,10 @@ $(function () { ], }, }, + { + target: 0, + data: 'projectName', + }, { target: 1, data: 'name', diff --git a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/DocumentWithoutContent.cs b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/DocumentWithoutContent.cs index cde44614ae..4ef9c0e232 100644 --- a/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/DocumentWithoutContent.cs +++ b/modules/docs/src/Volo.Docs.Domain/Volo/Docs/Documents/DocumentWithoutContent.cs @@ -7,6 +7,8 @@ namespace Volo.Docs.Documents public Guid Id { get; set; } public virtual Guid ProjectId { get; set; } + + public virtual string ProjectName { get; set; } public virtual string Name { get; set; } diff --git a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs index 7656975f16..1de28f537c 100644 --- a/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.EntityFrameworkCore/Volo/Docs/Documents/EFCoreDocumentRepository.cs @@ -67,23 +67,21 @@ namespace Volo.Docs.Documents int skipCount = 0, CancellationToken cancellationToken = default) { - var query = ApplyFilterForGetAll( + var query =await ApplyFilterForGetAll( await GetDbSetAsync(), projectId: projectId, name: name, version: version, languageCode: languageCode, - format: format, fileName: fileName, + format: format, creationTimeMin: creationTimeMin, creationTimeMax: creationTimeMax, lastUpdatedTimeMin: lastUpdatedTimeMin, lastUpdatedTimeMax: lastUpdatedTimeMax, lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin, lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax, - lastCachedTimeMin: lastCachedTimeMin, - lastCachedTimeMax: lastCachedTimeMax - ); + lastCachedTimeMin: lastCachedTimeMin, lastCachedTimeMax: lastCachedTimeMax); query = query.OrderBy(string.IsNullOrWhiteSpace(sorting) ? nameof(Document.Name) : sorting); return await query.PageBy(skipCount, maxResultCount).ToListAsync(GetCancellationToken(cancellationToken)); @@ -109,23 +107,21 @@ namespace Volo.Docs.Documents int skipCount = 0, CancellationToken cancellationToken = default) { - var query = ApplyFilterForGetAll( + var query = await ApplyFilterForGetAll( await GetDbSetAsync(), projectId: projectId, name: name, version: version, languageCode: languageCode, - format: format, fileName: fileName, + format: format, creationTimeMin: creationTimeMin, creationTimeMax: creationTimeMax, lastUpdatedTimeMin: lastUpdatedTimeMin, lastUpdatedTimeMax: lastUpdatedTimeMax, lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin, lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax, - lastCachedTimeMin: lastCachedTimeMin, - lastCachedTimeMax: lastCachedTimeMax - ); + lastCachedTimeMin: lastCachedTimeMin, lastCachedTimeMax: lastCachedTimeMax); return await query.LongCountAsync(GetCancellationToken(cancellationToken)); } @@ -153,7 +149,7 @@ namespace Volo.Docs.Documents return await (await GetDbSetAsync()).Where(x => x.Id == id).SingleAsync(cancellationToken: GetCancellationToken(cancellationToken)); } - protected virtual IQueryable ApplyFilterForGetAll( + protected virtual async Task> ApplyFilterForGetAll( IQueryable query, Guid? projectId, string name, @@ -200,19 +196,24 @@ namespace Volo.Docs.Documents d => d.LastCachedTime.Date >= lastCachedTimeMin.Value.Date) .WhereIf(lastCachedTimeMax.HasValue, d => d.LastCachedTime.Date <= lastCachedTimeMax.Value.Date) + .Join( (await GetDbContextAsync()).Projects, + d => d.ProjectId, + p => p.Id, + (d, p) => new { d, p }) .Select(x => new DocumentWithoutContent { - Id = x.Id, - ProjectId = x.ProjectId, - Name = x.Name, - Version = x.Version, - LanguageCode = x.LanguageCode, - FileName = x.FileName, - Format = x.Format, - CreationTime = x.CreationTime, - LastUpdatedTime = x.LastUpdatedTime, - LastSignificantUpdateTime = x.LastSignificantUpdateTime, - LastCachedTime = x.LastCachedTime + Id = x.d.Id, + ProjectId = x.d.ProjectId, + ProjectName = x.p.Name, + Name = x.d.Name, + Version = x.d.Version, + LanguageCode = x.d.LanguageCode, + FileName = x.d.FileName, + Format = x.d.Format, + CreationTime = x.d.CreationTime, + LastUpdatedTime = x.d.LastUpdatedTime, + LastSignificantUpdateTime = x.d.LastSignificantUpdateTime, + LastCachedTime = x.d.LastCachedTime }); } } diff --git a/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs b/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs index 0086624d43..88c7514ae4 100644 --- a/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs +++ b/modules/docs/src/Volo.Docs.MongoDB/Volo/Docs/Documents/MongoDocumentRepository.cs @@ -88,22 +88,21 @@ namespace Volo.Docs.Documents { return await - ApplyFilterForGetAll( + (await ApplyFilterForGetAll( await GetMongoQueryableAsync(cancellationToken), projectId: projectId, name: name, version: version, languageCode: languageCode, - format: format, fileName: fileName, + format: format, creationTimeMin: creationTimeMin, creationTimeMax: creationTimeMax, lastUpdatedTimeMin: lastUpdatedTimeMin, lastUpdatedTimeMax: lastUpdatedTimeMax, lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin, lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax, - lastCachedTimeMin: lastCachedTimeMin, - lastCachedTimeMax: lastCachedTimeMax) + lastCachedTimeMin: lastCachedTimeMin, lastCachedTimeMax: lastCachedTimeMax)) .OrderBy(string.IsNullOrWhiteSpace(sorting) ? "name asc" : sorting).As>() .PageBy>(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken)); @@ -132,22 +131,21 @@ namespace Volo.Docs.Documents return await - ApplyFilterForGetAll( + (await ApplyFilterForGetAll( await GetMongoQueryableAsync(cancellationToken), projectId: projectId, name: name, version: version, languageCode: languageCode, - format: format, fileName: fileName, + format: format, creationTimeMin: creationTimeMin, creationTimeMax: creationTimeMax, lastUpdatedTimeMin: lastUpdatedTimeMin, lastUpdatedTimeMax: lastUpdatedTimeMax, lastSignificantUpdateTimeMin: lastSignificantUpdateTimeMin, lastSignificantUpdateTimeMax: lastSignificantUpdateTimeMax, - lastCachedTimeMin: lastCachedTimeMin, - lastCachedTimeMax: lastCachedTimeMax) + lastCachedTimeMin: lastCachedTimeMin, lastCachedTimeMax: lastCachedTimeMax)) .OrderBy(string.IsNullOrWhiteSpace(sorting) ? "name asc" : sorting).As>() .PageBy>(skipCount, maxResultCount) .LongCountAsync(GetCancellationToken(cancellationToken)); @@ -158,7 +156,7 @@ namespace Volo.Docs.Documents return await (await GetMongoQueryableAsync(cancellationToken)).Where(x => x.Id == id).SingleAsync(GetCancellationToken(cancellationToken)); } - protected virtual IMongoQueryable ApplyFilterForGetAll( + protected virtual async Task> ApplyFilterForGetAll( IMongoQueryable query, Guid? projectId, string name, @@ -240,20 +238,25 @@ namespace Volo.Docs.Documents { query = query.Where(d => d.LastCachedTime.Date <= lastCachedTimeMax.Value.Date); } - - return query.Select(x => new DocumentWithoutContent + var join = query.Join( + (await GetDbContextAsync(cancellationToken)).Projects, + d => d.ProjectId, + p => p.Id, + (d, p) => new { Document = d, Project = p }); + return join.Select(x => new DocumentWithoutContent { - Id = x.Id, - ProjectId = x.ProjectId, - Name = x.Name, - Version = x.Version, - LanguageCode = x.LanguageCode, - FileName = x.FileName, - Format = x.Format, - CreationTime = x.CreationTime, - LastUpdatedTime = x.LastUpdatedTime, - LastSignificantUpdateTime = x.LastSignificantUpdateTime, - LastCachedTime = x.LastCachedTime + Id = x.Document.Id, + ProjectId = x.Document.ProjectId, + ProjectName = x.Project.Name, + Name = x.Document.Name, + Version = x.Document.Version, + LanguageCode = x.Document.LanguageCode, + FileName = x.Document.FileName, + Format = x.Document.Format, + CreationTime = x.Document.CreationTime, + LastUpdatedTime = x.Document.LastUpdatedTime, + LastSignificantUpdateTime = x.Document.LastSignificantUpdateTime, + LastCachedTime = x.Document.LastCachedTime }); } } From 5664a988a109fc50c0d1428cc1dc33ef7b28c289 Mon Sep 17 00:00:00 2001 From: Salih Date: Fri, 19 Aug 2022 15:39:06 +0300 Subject: [PATCH 031/106] dash removed --- .../Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml index 776d504395..2fab21f615 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml +++ b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml @@ -111,7 +111,6 @@ name="LastUpdatedTimeMin" class="form-control datepicker" placeholder="@L["StartDate"].Value"> - - Date: Fri, 19 Aug 2022 15:59:42 +0300 Subject: [PATCH 032/106] search button moved next to language code input --- .../Pages/Docs/Admin/Documents/Index.cshtml | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml index 2fab21f615..36e0c82462 100644 --- a/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml +++ b/modules/docs/src/Volo.Docs.Admin.Web/Pages/Docs/Admin/Documents/Index.cshtml @@ -34,7 +34,7 @@ - +
@L["Project"].Value
@@ -45,7 +45,7 @@
- +
@L["Name"].Value
@@ -56,7 +56,7 @@
- +
@L["Version"].Value
@@ -67,17 +67,19 @@
- +
@L["LanguageCode"].Value
+ id="LanguageCode" + name="LanguageCode" + class="form-control">
- + + + @L["AdvancedFilters"] @@ -85,7 +87,7 @@
-
+