已添加104个文件
已重命名36个文件
已删除225个文件
已复制2个文件
¶Ô±ÈÐÂÎļþ |
| | |
| | | # Paths |
| | | $rootFolder = (Get-Item -Path "./" -Verbose).FullName |
| | | |
| | | $serverFolder = Join-Path $rootFolder ("/server") |
| | | |
| | | Set-Location $serverFolder |
| | | & dotnet tool install --global dotnet-ef |
| | | |
| | | & dotnet restore -s https://nexus.sycdev.com/repository/nuget-group/index.json |
| | | |
| | | $migrationFolder = Join-Path $serverFolder ("/src/CMS.Plugin.WareCmsUtilityApi.MySQL") |
| | | Set-Location $migrationFolder |
| | | dotnet ef migrations add InitialCreate -c CMSPluginDbContext -o Migrations |
| | | |
| | | Set-Location $serverFolder |
| | | & dotnet build |
| | | |
| | | Set-Location $rootFolder |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # Paths |
| | | $rootFolder = (Get-Item -Path "./" -Verbose).FullName |
| | | |
| | | $webFolder = Join-Path $rootFolder ("/web") |
| | | |
| | | Set-Location $rootFolder |
| | | & npm install yarn -g |
| | | & npm install lmes-cli -g |
| | | |
| | | & lmes-cli create web |
| | | |
| | | Set-Location $webFolder |
| | | & yarn |
| | | & npm run build |
| | | |
| | | Set-Location $rootFolder |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | Microsoft Visual Studio Solution File, Format Version 12.00 |
| | | # Visual Studio Version 17 |
| | | VisualStudioVersion = 17.4.33110.190 |
| | | MinimumVisualStudioVersion = 10.0.40219.1 |
| | | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "è§£å³æ¹æ¡é¡¹", "è§£å³æ¹æ¡é¡¹", "{28C418E6-AF1D-4B74-ACDF-7B81FA4C256E}" |
| | | ProjectSection(SolutionItems) = preProject |
| | | .editorconfig = .editorconfig |
| | | .gitignore = .gitignore |
| | | common.props = common.props |
| | | common.test.props = common.test.props |
| | | configureawait.props = configureawait.props |
| | | delete-bin-obj-folders.bat = delete-bin-obj-folders.bat |
| | | Directory.Build.props = Directory.Build.props |
| | | NuGet.config = NuGet.config |
| | | package.reference.props = package.reference.props |
| | | publish.ps1 = publish.ps1 |
| | | README.md = README.md |
| | | stylecop.json = stylecop.json |
| | | EndProjectSection |
| | | EndProject |
| | | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{19F68F40-2A05-48EB-86F0-56928B3CCE9C}" |
| | | EndProject |
| | | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5632E2B3-5592-4C6A-9493-768E5B04804D}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi", "src\CMS.Plugin.WareCmsUtilityApi\CMS.Plugin.WareCmsUtilityApi.csproj", "{9926DE4C-376D-487E-9C64-494913D94379}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore", "src\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.csproj", "{0022A80F-6D52-4B58-B2B3-F029DB4AEC0A}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.Domain", "src\CMS.Plugin.WareCmsUtilityApi.Domain\CMS.Plugin.WareCmsUtilityApi.Domain.csproj", "{8B2BED13-2B0E-49B5-8B0A-F272D27B2F37}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.Domain.Shared", "src\CMS.Plugin.WareCmsUtilityApi.Domain.Shared\CMS.Plugin.WareCmsUtilityApi.Domain.Shared.csproj", "{F405C633-8100-49B8-A270-D5340A165742}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.Application.Contracts", "src\CMS.Plugin.WareCmsUtilityApi.Application.Contracts\CMS.Plugin.WareCmsUtilityApi.Application.Contracts.csproj", "{D65BB57E-618A-468C-AA28-BD8C9EBF0AF2}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.Application", "src\CMS.Plugin.WareCmsUtilityApi.Application\CMS.Plugin.WareCmsUtilityApi.Application.csproj", "{02CB86F3-E614-4193-8B7F-C2FB665C8A5A}" |
| | | EndProject |
| | | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{A68B3B6B-DDE8-431E-90F3-A9FEE1D14A53}" |
| | | ProjectSection(SolutionItems) = preProject |
| | | doc\Domain-Drive-Design.md = doc\Domain-Drive-Design.md |
| | | EndProjectSection |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.TestBase", "test\CMS.Plugin.WareCmsUtilityApi.TestBase\CMS.Plugin.WareCmsUtilityApi.TestBase.csproj", "{33999EE8-73A1-4CF2-BDFD-CE353B05A727}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Tests", "test\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Tests\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Tests.csproj", "{C6AFC427-C51D-4BD2-BBA6-8841D3495077}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.Domain.Tests", "test\CMS.Plugin.WareCmsUtilityApi.Domain.Tests\CMS.Plugin.WareCmsUtilityApi.Domain.Tests.csproj", "{74E86B03-F185-47B2-A4C3-04C1CEC84F14}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.Application.Tests", "test\CMS.Plugin.WareCmsUtilityApi.Application.Tests\CMS.Plugin.WareCmsUtilityApi.Application.Tests.csproj", "{731DE36F-27F5-48B8-865D-DA43C8910010}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.Abstractions", "src\CMS.Plugin.WareCmsUtilityApi.Abstractions\CMS.Plugin.WareCmsUtilityApi.Abstractions.csproj", "{87D957E4-FE12-4432-9B7B-827A98DD41D1}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.MySQL", "src\CMS.Plugin.WareCmsUtilityApi.MySQL\CMS.Plugin.WareCmsUtilityApi.MySQL.csproj", "{2F71D6DF-F19A-410C-BD79-F2F871E63902}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.PostgreSql", "src\CMS.Plugin.WareCmsUtilityApi.PostgreSql\CMS.Plugin.WareCmsUtilityApi.PostgreSql.csproj", "{698D9FFA-080C-4F22-9FBF-B9509B28A954}" |
| | | EndProject |
| | | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMS.Plugin.WareCmsUtilityApi.SqlServer", "src\CMS.Plugin.WareCmsUtilityApi.SqlServer\CMS.Plugin.WareCmsUtilityApi.SqlServer.csproj", "{521D17FF-BD3A-43B4-9BEE-183FDE3522F4}" |
| | | EndProject |
| | | Global |
| | | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
| | | Debug|Any CPU = Debug|Any CPU |
| | | Release|Any CPU = Release|Any CPU |
| | | EndGlobalSection |
| | | GlobalSection(ProjectConfigurationPlatforms) = postSolution |
| | | {9926DE4C-376D-487E-9C64-494913D94379}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {9926DE4C-376D-487E-9C64-494913D94379}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {9926DE4C-376D-487E-9C64-494913D94379}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {9926DE4C-376D-487E-9C64-494913D94379}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {0022A80F-6D52-4B58-B2B3-F029DB4AEC0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {0022A80F-6D52-4B58-B2B3-F029DB4AEC0A}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {0022A80F-6D52-4B58-B2B3-F029DB4AEC0A}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {0022A80F-6D52-4B58-B2B3-F029DB4AEC0A}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {8B2BED13-2B0E-49B5-8B0A-F272D27B2F37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {8B2BED13-2B0E-49B5-8B0A-F272D27B2F37}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {8B2BED13-2B0E-49B5-8B0A-F272D27B2F37}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {8B2BED13-2B0E-49B5-8B0A-F272D27B2F37}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {F405C633-8100-49B8-A270-D5340A165742}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {F405C633-8100-49B8-A270-D5340A165742}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {F405C633-8100-49B8-A270-D5340A165742}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {F405C633-8100-49B8-A270-D5340A165742}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {D65BB57E-618A-468C-AA28-BD8C9EBF0AF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {D65BB57E-618A-468C-AA28-BD8C9EBF0AF2}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {D65BB57E-618A-468C-AA28-BD8C9EBF0AF2}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {D65BB57E-618A-468C-AA28-BD8C9EBF0AF2}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {02CB86F3-E614-4193-8B7F-C2FB665C8A5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {02CB86F3-E614-4193-8B7F-C2FB665C8A5A}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {02CB86F3-E614-4193-8B7F-C2FB665C8A5A}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {02CB86F3-E614-4193-8B7F-C2FB665C8A5A}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {33999EE8-73A1-4CF2-BDFD-CE353B05A727}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {33999EE8-73A1-4CF2-BDFD-CE353B05A727}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {33999EE8-73A1-4CF2-BDFD-CE353B05A727}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {33999EE8-73A1-4CF2-BDFD-CE353B05A727}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {C6AFC427-C51D-4BD2-BBA6-8841D3495077}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {C6AFC427-C51D-4BD2-BBA6-8841D3495077}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {C6AFC427-C51D-4BD2-BBA6-8841D3495077}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {C6AFC427-C51D-4BD2-BBA6-8841D3495077}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {74E86B03-F185-47B2-A4C3-04C1CEC84F14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {74E86B03-F185-47B2-A4C3-04C1CEC84F14}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {74E86B03-F185-47B2-A4C3-04C1CEC84F14}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {74E86B03-F185-47B2-A4C3-04C1CEC84F14}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {731DE36F-27F5-48B8-865D-DA43C8910010}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {731DE36F-27F5-48B8-865D-DA43C8910010}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {731DE36F-27F5-48B8-865D-DA43C8910010}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {731DE36F-27F5-48B8-865D-DA43C8910010}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {87D957E4-FE12-4432-9B7B-827A98DD41D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {87D957E4-FE12-4432-9B7B-827A98DD41D1}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {87D957E4-FE12-4432-9B7B-827A98DD41D1}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {87D957E4-FE12-4432-9B7B-827A98DD41D1}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {2F71D6DF-F19A-410C-BD79-F2F871E63902}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {2F71D6DF-F19A-410C-BD79-F2F871E63902}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {2F71D6DF-F19A-410C-BD79-F2F871E63902}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {2F71D6DF-F19A-410C-BD79-F2F871E63902}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {698D9FFA-080C-4F22-9FBF-B9509B28A954}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {698D9FFA-080C-4F22-9FBF-B9509B28A954}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {698D9FFA-080C-4F22-9FBF-B9509B28A954}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {698D9FFA-080C-4F22-9FBF-B9509B28A954}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | {521D17FF-BD3A-43B4-9BEE-183FDE3522F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
| | | {521D17FF-BD3A-43B4-9BEE-183FDE3522F4}.Debug|Any CPU.Build.0 = Debug|Any CPU |
| | | {521D17FF-BD3A-43B4-9BEE-183FDE3522F4}.Release|Any CPU.ActiveCfg = Release|Any CPU |
| | | {521D17FF-BD3A-43B4-9BEE-183FDE3522F4}.Release|Any CPU.Build.0 = Release|Any CPU |
| | | EndGlobalSection |
| | | GlobalSection(SolutionProperties) = preSolution |
| | | HideSolutionNode = FALSE |
| | | EndGlobalSection |
| | | GlobalSection(NestedProjects) = preSolution |
| | | {9926DE4C-376D-487E-9C64-494913D94379} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | {0022A80F-6D52-4B58-B2B3-F029DB4AEC0A} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | {8B2BED13-2B0E-49B5-8B0A-F272D27B2F37} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | {F405C633-8100-49B8-A270-D5340A165742} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | {D65BB57E-618A-468C-AA28-BD8C9EBF0AF2} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | {02CB86F3-E614-4193-8B7F-C2FB665C8A5A} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | {33999EE8-73A1-4CF2-BDFD-CE353B05A727} = {5632E2B3-5592-4C6A-9493-768E5B04804D} |
| | | {C6AFC427-C51D-4BD2-BBA6-8841D3495077} = {5632E2B3-5592-4C6A-9493-768E5B04804D} |
| | | {74E86B03-F185-47B2-A4C3-04C1CEC84F14} = {5632E2B3-5592-4C6A-9493-768E5B04804D} |
| | | {731DE36F-27F5-48B8-865D-DA43C8910010} = {5632E2B3-5592-4C6A-9493-768E5B04804D} |
| | | {87D957E4-FE12-4432-9B7B-827A98DD41D1} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | {2F71D6DF-F19A-410C-BD79-F2F871E63902} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | {698D9FFA-080C-4F22-9FBF-B9509B28A954} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | {521D17FF-BD3A-43B4-9BEE-183FDE3522F4} = {19F68F40-2A05-48EB-86F0-56928B3CCE9C} |
| | | EndGlobalSection |
| | | GlobalSection(ExtensibilityGlobals) = postSolution |
| | | SolutionGuid = {220123E7-A888-4DE7-8F9A-8FE271543889} |
| | | EndGlobalSection |
| | | EndGlobal |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # WareCmsUtilityApi |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | # publishFolder |
| | | $publishFolder= $args[0] |
| | | |
| | | # Paths |
| | | $rootFolder = (Get-Item -Path "./" -Verbose).FullName |
| | | if ([String]::IsNullOrEmpty($publishFolder)) { |
| | | $publishFolder = Join-Path $rootFolder "output/publish" |
| | | $hasPath = Test-Path($publishFolder) |
| | | if (-Not $hasPath) { |
| | | new-item -path $rootFolder -name "output/publish" -type directory |
| | | } |
| | | } |
| | | Write-Host ("Publish Output " + $publishFolder) |
| | | |
| | | # List of projects |
| | | $projects = ( |
| | | "src/CMS.Plugin.WareCmsUtilityApi" |
| | | ) |
| | | |
| | | # Rebuild solution |
| | | Set-Location $rootFolder |
| | | dotnet restore -s https://nexus.sycdev.com/repository/nuget-hosted/ --runtime win-x64 |
| | | # dotnet restore --configfile NuGet.config --runtime win-x64 |
| | | Write-Host ("Restore Completed ! ") |
| | | # Publish all projects |
| | | foreach($project in $projects) { |
| | | $projectFolder = Join-Path $rootFolder $project |
| | | $projectName = $project.Substring($project.LastIndexOf("/") + 1) |
| | | Set-Location $projectFolder |
| | | Write-Host ("Publish " + $projectName) |
| | | # & dotnet publish ($projectName + ".csproj ") --configuration Release --output (Join-Path $publishFolder ("/" + $projectName.ToLower())) --nologo --verbosity quiet --no-restore |
| | | & dotnet publish ($projectName + ".csproj ") --configuration Release --output (Join-Path $publishFolder ("/" + $projectName.ToLower())) --nologo --verbosity quiet --no-restore --runtime win-x64 |
| | | } |
| | | |
| | | Write-Host ("Publish Completed ! ") |
| | | |
| | | # Go back to the root folder |
| | | Set-Location $rootFolder |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Abstractions; |
| | | |
| | | /// <summary> |
| | | /// æµç¨ä¸å¡æ©å±æ¨¡å |
| | | /// </summary> |
| | | public class CMSPluginWareCmsUtilityApiAbstractionsModule |
| | | { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Abstractions |
| | | { |
| | | /// <summary> |
| | | /// æ©å±æ¹æ³ |
| | | /// </summary> |
| | | public static class CMSPluginWareCmsUtilityApiExtensions |
| | | { |
| | | /// <summary> |
| | | /// Tries the add setting management. |
| | | /// </summary> |
| | | /// <param name="services">The services.</param> |
| | | /// <param name="configureOptions">The configure options.</param> |
| | | /// <returns></returns> |
| | | public static IServiceCollection TryAddWareCmsUtilityApi(this IServiceCollection services, Action<CMSPluginWareCmsUtilityApiOptions>? configureOptions = null) |
| | | { |
| | | if (configureOptions == null) |
| | | { |
| | | services.AddOptions().Configure<CMSPluginWareCmsUtilityApiOptions>(options => {}); |
| | | } |
| | | else |
| | | { |
| | | services.AddOptions().PostConfigure(configureOptions); |
| | | } |
| | | |
| | | return services; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Abstractions |
| | | { |
| | | /// <summary> |
| | | /// åè½å®ä¹. |
| | | /// </summary> |
| | | public class CMSPluginWareCmsUtilityApiFeatures |
| | | { |
| | | /// <summary> |
| | | /// The prefix |
| | | /// </summary> |
| | | private const string Prefix = "LMES"; |
| | | |
| | | /// <summary> |
| | | /// GroupName |
| | | /// </summary> |
| | | public const string GroupName = Prefix + ".WareCmsUtilityApi"; |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦å¼å¯ |
| | | /// </summary> |
| | | public const string Enable = GroupName + ".Enable"; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.MesSuite.Abstractions.Models; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Abstractions |
| | | { |
| | | public class CMSPluginWareCmsUtilityApiOptions |
| | | { |
| | | public CMSPluginWareCmsUtilityApiOptions() |
| | | { |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ©å±å±æ§ |
| | | /// </summary> |
| | | public List<ExtraProperty> ExtraProperties { get; set; } = new(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Abstractions |
| | | { |
| | | /// <summary> |
| | | /// CMSSettingNames |
| | | /// </summary> |
| | | public static class CMSPluginWareCmsUtilityApiSettings |
| | | { |
| | | /// <summary> |
| | | /// The prefix |
| | | /// </summary> |
| | | private const string Prefix = "SCMS"; |
| | | |
| | | /// <summary> |
| | | /// The application settings prefix |
| | | /// </summary> |
| | | private const string AppSettingsPrefix = Prefix + ".AppSettings"; |
| | | |
| | | /// <summary> |
| | | /// ç»ä»¶ç¶æï¼0=å
³é,1=å¼å¯ |
| | | /// </summary> |
| | | public const string PluginState = AppSettingsPrefix + ".WareCmsUtilityApi.PluginState"; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using SYC.Flow.Kernel; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Abstractions |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApi æµç¨æå¡ |
| | | /// </summary> |
| | | public interface IWareCmsUtilityApiFlowService |
| | | { |
| | | /// <summary> |
| | | /// å·¥èºæµç¨å¤ç |
| | | /// </summary> |
| | | Task ProcessAsync(ProcessflowEventArgs args); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System.ComponentModel; |
| | | using System.Runtime.Serialization; |
| | | using CMS.Plugin.FlowManagement.Abstractions.Enums; |
| | | using CMS.Plugin.FlowManagement.Abstractions.FlowBusiness.Activitys; |
| | | using CMS.Plugin.MesSuite.Abstractions.Models; |
| | | using CMS.Plugin.OrderManagement.Abstractions.Models; |
| | | using CMS.Plugin.ProcessManagement.Abstractions.Models; |
| | | using CMS.Plugin.TraceManagement.Abstractions.Models.Traces; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Logging; |
| | | using SYC.Flow.Kernel; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Abstractions |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApi ä¸å¡æ¥éª¤ |
| | | /// </summary> |
| | | [Design("WareCmsUtilityApi", "WareCmsUtilityApi ä¸å¡æ¥éª¤", Sort = 99), Category("å®å¶æ¥éª¤")] |
| | | [Serializable] |
| | | public class WareCmsUtilityApiActivity : BusinessActivity |
| | | { |
| | | /// <summary> |
| | | /// é
ç½®å±æ§1 |
| | | /// </summary> |
| | | [Design("é
ç½®å±æ§1", "é
ç½®å±æ§1", Sort = 1), Category("é
置信æ¯")] |
| | | [DataMember] |
| | | public string MyProperty1 { get; set; } |
| | | |
| | | /// <summary> |
| | | /// é
ç½®å±æ§2 |
| | | /// </summary> |
| | | [Design("é
ç½®å±æ§2", "é
ç½®å±æ§2", Sort = 2), Category("é
置信æ¯")] |
| | | [DataMember] |
| | | public int MyProperty2 { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æµç¨ä¸ä¸ææ è¯éå |
| | | /// </summary> |
| | | public override List<FlowItemKey> FlowItemKeys => GetFlowItemKeys(); |
| | | |
| | | /// <summary> |
| | | /// å·¥èºæµç¨å¤ç |
| | | /// </summary> |
| | | public override async Task ProcessAsync(ProcessflowEventArgs args) |
| | | { |
| | | // å·¥èºæ¨¡å |
| | | var processModel = Flow.DataItems.ApplicationData as ProcessModel; |
| | | |
| | | // 工忍¡å |
| | | var orderModel = Flow.DataItems[FlowItemCollection.OrderModel] as OrderModel; |
| | | |
| | | // äº§åæ¨¡å |
| | | var productModel = Flow.DataItems[FlowItemCollection.ProductModel] as AssociationProductModel; |
| | | |
| | | // 追溯模å |
| | | var traceModel = Flow.DataItems[FlowItemCollection.TraceModel] as TraceModel; |
| | | |
| | | Flow.Logger.LogInformation($"æ§è¡æµç¨ï¼å®ä¾={Flow.Instance.ProcID} -> {Flow.Name} -> {Name} WareCmsUtilityApiActivity"); |
| | | |
| | | // ä¸å¡å¤ç |
| | | // ç±äºServiceProvideræ¥æºäºFlowç»ä»¶ï¼æ¤å¤éå
±äº«CMS.Plugin.WareCmsUtilityApi.Abstractionsç¨åºéï¼å¦åæ æ³è°ç¨ï¼ä¿®æ¹CMS.Plugin.WareCmsUtilityApi项ç®ä¸çCMSPluginModule.csæä»¶ï¼åæ¶æ³¨éGetSharedAssemblies()æ¹æ³ |
| | | var warecmsutilityapiFlowService = Flow.ServiceProvider.GetService<IWareCmsUtilityApiFlowService>(); |
| | | if (warecmsutilityapiFlowService != null) |
| | | { |
| | | await warecmsutilityapiFlowService.ProcessAsync(args); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Gets the flow item keys. |
| | | /// </summary> |
| | | protected virtual List<FlowItemKey> GetFlowItemKeys() |
| | | { |
| | | var result = new List<FlowItemKey>(); |
| | | return result; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <Import Project="../../common.props" /> |
| | | <Import Project="../../configureawait.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | <GenerateDocumentationFile>True</GenerateDocumentationFile> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.Authorization.Abstractions" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="MiniExcel" Version="1.31.3" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.Domain.Shared\CMS.Plugin.WareCmsUtilityApi.Domain.Shared.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared; |
| | | using Volo.Abp.Application; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts; |
| | | |
| | | /// <summary> |
| | | /// æä»¶åºç¨æå¡å¥çº¦æ¨¡å |
| | | /// </summary> |
| | | [DependsOn( |
| | | typeof(CMSPluginDomainSharedModule), |
| | | typeof(AbpDddApplicationContractsModule) |
| | | )] |
| | | public class CMSPluginApplicationContractsModule : AbpModule |
| | | { |
| | | /// <inheritdoc /> |
| | | public override void PreConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | CMSPluginDtoExtensions.Configure(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Threading; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts; |
| | | |
| | | /// <summary> |
| | | /// Dtoæ©å± |
| | | /// </summary> |
| | | public static class CMSPluginDtoExtensions |
| | | { |
| | | private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
| | | |
| | | /// <summary> |
| | | /// Configures this instance. |
| | | /// </summary> |
| | | public static void Configure() |
| | | { |
| | | OneTimeRunner.Run(() => |
| | | { |
| | | /* You can add extension properties to DTOs |
| | | * defined in the depended modules. |
| | | * |
| | | * Example: |
| | | * |
| | | * ObjectExtensionManager.Instance |
| | | * .AddOrUpdateProperty<IdentityRoleDto, string>("Title"); |
| | | * |
| | | * See the documentation for more: |
| | | * https://docs.abp.io/en/abp/latest/Object-Extensions |
| | | */ |
| | | }); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Application.Dtos; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | |
| | | /// <summary> |
| | | /// Sampleæ¥è¯¢åæ°å¯¹è±¡ |
| | | /// </summary> |
| | | public class GetSamplesInput : ExtensiblePagedAndSortedResultRequestDto |
| | | { |
| | | /// <summary> |
| | | /// Gets or sets the filter. |
| | | /// </summary> |
| | | public string Filter { get; set; } |
| | | |
| | | /// <summary> |
| | | /// Gets or sets the name. |
| | | /// </summary> |
| | | public string Name { get; set; } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | |
| | | /// <summary> |
| | | /// Sampleåå»ºåæ°å¯¹è±¡ |
| | | /// </summary> |
| | | public class SampleCreateDto : SampleCreateOrUpdateDtoBase |
| | | { |
| | | /// <summary> |
| | | /// æåº |
| | | /// </summary> |
| | | public virtual int? Sort { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦ç¦ç¨ |
| | | /// </summary> |
| | | public bool? IsDisabled { get; set; } = false; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Application.Dtos; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | |
| | | /// <summary> |
| | | /// Sampleåå»ºææ´æ°åºç±» |
| | | /// </summary> |
| | | public abstract class SampleCreateOrUpdateDtoBase : ExtensibleEntityDto |
| | | { |
| | | /// <summary> |
| | | /// ç¼å· |
| | | /// </summary> |
| | | public virtual string Code { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åç§° |
| | | /// </summary> |
| | | public virtual string Name { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | | public virtual string Remark { get; set; } |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="SampleCreateOrUpdateDtoBase"/> class. |
| | | /// </summary> |
| | | public SampleCreateOrUpdateDtoBase() : base(false) |
| | | { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Application.Dtos; |
| | | using Volo.Abp.Domain.Entities; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | |
| | | /// <summary> |
| | | /// Sampleæ°æ®åæ°å¯¹è±¡ |
| | | /// </summary> |
| | | public class SampleDto : ExtensibleEntityDto<Guid>, IHasConcurrencyStamp |
| | | { |
| | | /// <summary> |
| | | /// ç¼å· |
| | | /// </summary> |
| | | public virtual string Code { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åç§° |
| | | /// </summary> |
| | | public virtual string Name { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æåº |
| | | /// </summary> |
| | | public virtual int Sort { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | | public virtual string Remark { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦ç¦ç¨ |
| | | /// </summary> |
| | | public virtual bool? IsDisabled { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å¹¶åæ³ |
| | | /// </summary> |
| | | public string ConcurrencyStamp { get; set; } |
| | | |
| | | /// <summary> |
| | | /// Gets the export data. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Dictionary<string, object> GetExportData() |
| | | { |
| | | var exportData = new Dictionary<string, object>(); |
| | | foreach (var property in this.GetType().GetProperties()) |
| | | { |
| | | exportData.Add(property.Name, property.GetValue(this)); |
| | | } |
| | | |
| | | return exportData; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Domain.Entities; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | |
| | | /// <summary> |
| | | /// Sampleæ´æ°åæ°å¯¹è±¡ |
| | | /// </summary> |
| | | public class SampleUpdateDto : SampleCreateOrUpdateDtoBase, IHasConcurrencyStamp |
| | | { |
| | | /// <summary> |
| | | /// å¹¶åæ³ |
| | | /// </summary> |
| | | public string ConcurrencyStamp { get; set; } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using MiniExcelLibs.Attributes; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples |
| | | { |
| | | /// <summary> |
| | | /// Sampleså¯¼åºæ¨¡å |
| | | /// </summary> |
| | | public class SamplesExportModel |
| | | { |
| | | /// <summary> |
| | | /// Sampleå¯¼åºæ¨¡å |
| | | /// </summary> |
| | | public class WorkSectionExportModel |
| | | { |
| | | [ExcelColumn(Name = "åç§°", Width = 25)] |
| | | public virtual string Name { get; set; } |
| | | |
| | | [ExcelColumn(Name = "ç¼å·", Width = 25)] |
| | | public virtual string Code { get; set; } |
| | | |
| | | [ExcelColumn(Name = "夿³¨", Width = 25)] |
| | | public virtual string Remark { get; set; } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using static CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples.SamplesExportModel; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples |
| | | { |
| | | /// <summary> |
| | | /// Samples导å
¥æ¨¡å |
| | | /// </summary> |
| | | public class SamplesImportModel |
| | | { |
| | | private List<SampleImportModel> _samples = new(); |
| | | |
| | | public List<SampleImportModel> Samples |
| | | { |
| | | get => _samples; |
| | | set |
| | | { |
| | | _samples = value; |
| | | var rowIndex = 2; |
| | | _samples?.ForEach(x => x.RowIndex = rowIndex++); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Sample导å
¥æ¨¡å |
| | | /// </summary> |
| | | public class SampleImportModel : WorkSectionExportModel |
| | | { |
| | | /// <summary> |
| | | /// è¡å· |
| | | /// </summary> |
| | | public int RowIndex { get; set; } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Application.Services; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts; |
| | | |
| | | /// <summary> |
| | | /// æ¥è¯¢åºç¨æå¡ |
| | | /// </summary> |
| | | public interface ICMSPluginQueryAppService : IApplicationService |
| | | { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | using Volo.Abp.Application.Services; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Services; |
| | | |
| | | /// <summary> |
| | | /// Sampleåºç¨æå¡ |
| | | /// </summary> |
| | | public interface ISampleAppService : ICrudAppService<SampleDto, Guid, GetSamplesInput, SampleCreateDto, SampleUpdateDto> |
| | | { |
| | | /// <summary> |
| | | /// Clones the asynchronous. |
| | | /// </summary> |
| | | /// <param name="ids">The ids.</param> |
| | | /// <returns></returns> |
| | | Task<List<SampleDto>> CloneAsync(IEnumerable<Guid> ids); |
| | | |
| | | /// <summary> |
| | | /// Deletes the many asynchronous. |
| | | /// </summary> |
| | | /// <param name="ids">The ids.</param> |
| | | /// <returns></returns> |
| | | Task DeleteManyAsync(IEnumerable<Guid> ids); |
| | | |
| | | /// <summary> |
| | | /// Adjusts the sort asynchronous. |
| | | /// </summary> |
| | | /// <param name="id">The identifier.</param> |
| | | /// <param name="sort">The sort.</param> |
| | | /// <returns></returns> |
| | | Task AdjustSortAsync(Guid id, int sort); |
| | | |
| | | /// <summary> |
| | | /// Imports the asynchronous. |
| | | /// </summary> |
| | | /// <param name="input">The input.</param> |
| | | /// <returns></returns> |
| | | Task ImportAsync(SamplesImportModel input); |
| | | |
| | | /// <summary> |
| | | /// Exports the asynchronous. |
| | | /// </summary> |
| | | /// <param name="input">The input.</param> |
| | | /// <returns></returns> |
| | | Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetSamplesInput input); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <Import Project="../../common.props" /> |
| | | <Import Project="../../configureawait.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Volo.Abp.Dapper" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.AutoMapper" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.Ddd.Application" Version="$(ABPPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.Application.Contracts\CMS.Plugin.WareCmsUtilityApi.Application.Contracts.csproj" /> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.Domain\CMS.Plugin.WareCmsUtilityApi.Domain.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Localization; |
| | | using Volo.Abp.Application.Services; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application; |
| | | |
| | | /// <summary> |
| | | /// Inherit your application services from this class. |
| | | /// </summary> |
| | | public abstract class CMSPluginAppService : ApplicationService |
| | | { |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CMSPluginAppService"/> class. |
| | | /// </summary> |
| | | protected CMSPluginAppService() |
| | | { |
| | | ObjectMapperContext = typeof(CMSPluginApplicationModule); |
| | | LocalizationResource = typeof(WareCmsUtilityApiResource); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Volo.Abp.Application; |
| | | using Volo.Abp.AutoMapper; |
| | | using Volo.Abp.EventBus; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application; |
| | | |
| | | /// <summary> |
| | | /// æä»¶åºç¨æå¡æ¨¡å |
| | | /// </summary> |
| | | [DependsOn( |
| | | typeof(CMSPluginDomainModule), |
| | | typeof(CMSPluginApplicationContractsModule), |
| | | typeof(AbpAutoMapperModule), |
| | | typeof(AbpEventBusModule), |
| | | typeof(AbpDddApplicationModule) |
| | | )] |
| | | public class CMSPluginApplicationModule : AbpModule |
| | | { |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | context.Services.AddAutoMapperObjectMapper<CMSPluginApplicationModule>(); |
| | | Configure<AbpAutoMapperOptions>(options => |
| | | { |
| | | options.AddMaps<CMSPluginApplicationModule>(validate: true); |
| | | }); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Data; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application; |
| | | |
| | | /// <inheritdoc /> |
| | | public class CMSPluginQueryAppService : CMSPluginAppService, ICMSPluginQueryAppService |
| | | { |
| | | private readonly ICMSPluginDapperRepository _dapperRepository; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CMSPluginQueryAppService"/> class. |
| | | /// </summary> |
| | | /// <param name="dapperRepository">The dapper repository.</param> |
| | | public CMSPluginQueryAppService(ICMSPluginDapperRepository dapperRepository) |
| | | { |
| | | _dapperRepository = dapperRepository; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Services; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Samples; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Application.Dtos; |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.ObjectExtending; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Implements; |
| | | |
| | | /// <inheritdoc /> |
| | | public class SampleAppService : CMSPluginAppService, ISampleAppService |
| | | { |
| | | private readonly ISampleRepository _sampleRepository; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="SampleAppService"/> class. |
| | | /// </summary> |
| | | /// <param name="sampleRepository">The task job repository.</param> |
| | | public SampleAppService(ISampleRepository sampleRepository) |
| | | { |
| | | _sampleRepository = sampleRepository; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual async Task<SampleDto> GetAsync(Guid id) |
| | | { |
| | | return ObjectMapper.Map<Sample, SampleDto>(await _sampleRepository.GetAsync(id)); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual async Task<PagedResultDto<SampleDto>> GetListAsync(GetSamplesInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | | if (input.Sorting.IsNullOrWhiteSpace()) |
| | | { |
| | | input.Sorting = nameof(Sample.Sort); |
| | | } |
| | | |
| | | var specification = new SampleSpecification(input.Name); |
| | | var count = await _sampleRepository.GetCountAsync(input.Filter, specification); |
| | | var list = await _sampleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification); |
| | | |
| | | return new PagedResultDto<SampleDto>(count, ObjectMapper.Map<List<Sample>, List<SampleDto>>(list)); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual async Task<SampleDto> CreateAsync(SampleCreateDto input) |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var exist = await _sampleRepository.NameExistAsync(input.Name); |
| | | if (exist) |
| | | { |
| | | throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.Name]); |
| | | } |
| | | |
| | | var maxSort = await _sampleRepository.GetMaxSortAsync(); |
| | | var sort = input.Sort ?? maxSort; |
| | | var sample = new Sample(GuidGenerator.Create(), input.Code, input.Name, sort, input.Remark); |
| | | input.MapExtraPropertiesTo(sample, MappingPropertyDefinitionChecks.None); |
| | | |
| | | await _sampleRepository.InsertAsync(sample); |
| | | |
| | | if (input.Sort.HasValue && sample.Sort != maxSort) |
| | | { |
| | | await AdjustSortAsync(sample.Id, sample.Sort); |
| | | } |
| | | |
| | | return ObjectMapper.Map<Sample, SampleDto>(sample); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual async Task<SampleDto> UpdateAsync(Guid id, SampleUpdateDto input) |
| | | { |
| | | await CheckCreateOrUpdateDtoAsync(input); |
| | | |
| | | var sample = await _sampleRepository.GetAsync(id); |
| | | var exist = await _sampleRepository.NameExistAsync(input.Name, sample.Id); |
| | | if (exist) |
| | | { |
| | | throw new UserFriendlyException(L[CMSPluginDomainErrorCodes.NameAlreadyExists, input.Name]); |
| | | } |
| | | |
| | | sample.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp); |
| | | input.MapExtraPropertiesTo(sample, MappingPropertyDefinitionChecks.None); |
| | | |
| | | sample.Update(input.Code, input.Name, input.Remark); |
| | | |
| | | await _sampleRepository.UpdateAsync(sample); |
| | | |
| | | return ObjectMapper.Map<Sample, SampleDto>(sample); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<List<SampleDto>> CloneAsync(IEnumerable<Guid> ids) |
| | | { |
| | | var samples = new List<Sample>(); |
| | | if (ids != null) |
| | | { |
| | | var sort = await _sampleRepository.GetMaxSortAsync(); |
| | | foreach (var id in ids) |
| | | { |
| | | var sample = await _sampleRepository.FindAsync(id); |
| | | if (sample != null) |
| | | { |
| | | var name = sample.Name + SampleConsts.CloneTag; |
| | | var notExist = false; |
| | | while (!notExist) |
| | | { |
| | | var exist = await _sampleRepository.NameExistAsync(name); |
| | | if (exist || samples.Any(x => x.Name == name)) |
| | | { |
| | | name += SampleConsts.CloneTag; |
| | | continue; |
| | | } |
| | | |
| | | notExist = true; |
| | | } |
| | | |
| | | sample = await _sampleRepository.InsertAsync(sample.Clone(GuidGenerator.Create(), name, sort++)); |
| | | samples.Add(sample); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return ObjectMapper.Map<List<Sample>, List<SampleDto>>(samples); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual Task DeleteAsync(Guid id) |
| | | { |
| | | return _sampleRepository.DeleteAsync(id); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task DeleteManyAsync(IEnumerable<Guid> ids) |
| | | { |
| | | foreach (var id in ids) |
| | | { |
| | | await DeleteAsync(id); |
| | | } |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual async Task AdjustSortAsync(Guid id, int sort) |
| | | { |
| | | var list = await _sampleRepository.GetListAsync(nameof(Sample.Sort)); |
| | | if (list != null && list.Any()) |
| | | { |
| | | var initSort = 1; |
| | | list.ForEach(x => x.AdjustSort(initSort++)); |
| | | var entity = list.FirstOrDefault(x => x.Id == id); |
| | | if (entity != null) |
| | | { |
| | | if (sort == 1) |
| | | { |
| | | list.Where(x => x.Id != id).ToList()?.ForEach(x => x.AdjustSort(x.Sort + 1)); |
| | | } |
| | | else if (entity.Sort > sort) |
| | | { |
| | | list.Where(x => x.Id != id && x.Sort >= sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort + 1)); |
| | | list.Where(x => x.Id != id && x.Sort < sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort - 1)); |
| | | } |
| | | else if (entity.Sort < sort) |
| | | { |
| | | list.Where(x => x.Id != id && x.Sort > sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort + 1)); |
| | | list.Where(x => x.Id != id && x.Sort <= sort).ToList()?.ForEach(x => x.AdjustSort(x.Sort - 1)); |
| | | } |
| | | |
| | | entity.AdjustSort(sort); |
| | | } |
| | | } |
| | | |
| | | await _sampleRepository.UpdateManyAsync(list); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task ImportAsync(SamplesImportModel input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | | var sampleCreateDtos = new List<(int RowIndex, SampleCreateDto Item)>(); |
| | | var sampleUpdateDtos = new List<(int RowIndex, Guid Id, SampleUpdateDto Item)>(); |
| | | var samples = input.Samples; |
| | | |
| | | if (samples != null && samples.Any()) |
| | | { |
| | | #region 导å
¥æ ¡éª |
| | | |
| | | // 夿åç§°æ¯å¦éå¤ï¼å¹¶è¾åºç¬¬å è¡éå¤ |
| | | var duplicateSamples = samples.GroupBy(x => x.Name).Where(x => x.Count() > 1).ToList(); |
| | | if (duplicateSamples?.Any() == true) |
| | | { |
| | | var duplicateSampleMsgs = duplicateSamples.Select(x => $"第 {string.Join(",", x.Select(x => x.RowIndex))} è¡ï¼{x.Key} åç§°éå¤"); |
| | | var errorMsg = $"导å
¥å¤±è´¥ï¼é
ç½®ï¼ {string.Join(",", duplicateSampleMsgs)}ï¼ç»æ¢å¯¼å
¥"; |
| | | throw new UserFriendlyException(errorMsg); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | foreach (var sample in samples) |
| | | { |
| | | if (sample.Code.IsNullOrWhiteSpace() && sample.Name.IsNullOrWhiteSpace()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (sample.Name.IsNullOrWhiteSpace()) |
| | | { |
| | | var errorMsg = $"导å
¥å¤±è´¥ï¼é
ç½®ï¼ç¬¬{sample.RowIndex}è¡ï¼Sampleåç§°ä¸è½ä¸ºç©º"; |
| | | throw new UserFriendlyException(errorMsg); |
| | | } |
| | | |
| | | var oldSample = await _sampleRepository.FindByNameAsync(sample.Name); |
| | | if (oldSample != null) |
| | | { |
| | | var sampleUpdateDto = new SampleUpdateDto |
| | | { |
| | | Code = sample.Code, |
| | | Name = sample.Name, |
| | | Remark = sample.Remark, |
| | | }; |
| | | |
| | | sampleUpdateDtos.Add((sample.RowIndex, oldSample.Id, sampleUpdateDto)); |
| | | } |
| | | else |
| | | { |
| | | var sampleCreateDto = new SampleCreateDto |
| | | { |
| | | Code = sample.Code, |
| | | Name = sample.Name, |
| | | Remark = sample.Remark, |
| | | }; |
| | | |
| | | sampleCreateDtos.Add((sample.RowIndex, sampleCreateDto)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // æ°å¢ |
| | | foreach (var sampleDto in sampleCreateDtos) |
| | | { |
| | | try |
| | | { |
| | | await CreateAsync(sampleDto.Item); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var errorMsg = $"导å
¥å¤±è´¥ï¼é
ç½®ï¼ç¬¬{sampleDto.RowIndex}è¡ï¼{e.Message}ï¼ç»æ¢å¯¼å
¥"; |
| | | throw new UserFriendlyException(errorMsg); |
| | | } |
| | | } |
| | | |
| | | // æ´æ° |
| | | foreach (var sampleDto in sampleUpdateDtos) |
| | | { |
| | | try |
| | | { |
| | | await UpdateAsync(sampleDto.Id, sampleDto.Item); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | var errorMsg = $"导å
¥å¤±è´¥ï¼é
ç½®ï¼ç¬¬{sampleDto.RowIndex}è¡ï¼{e.Message}ï¼ç»æ¢å¯¼å
¥"; |
| | | throw new UserFriendlyException(errorMsg); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<(Dictionary<string, object> Sheets, string FileName)> ExportAsync(GetSamplesInput input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | |
| | | if (input.Sorting.IsNullOrWhiteSpace()) |
| | | { |
| | | input.Sorting = nameof(Sample.Sort); |
| | | } |
| | | |
| | | var specification = new SampleSpecification(input.Name); |
| | | var list = await _sampleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount, input.Filter, specification, includeDetails: true); |
| | | var result = ObjectMapper.Map<List<Sample>, List<SampleDto>>(list); |
| | | |
| | | var sheets = new Dictionary<string, object> |
| | | { |
| | | ["é
ç½®"] = result.Select(x => x.GetExportData()).ToList(), |
| | | }; |
| | | |
| | | var fileName = result.Count > 1 ? "Sampleå表" : result.Count == 1 ? result.First()?.Name : "Sample模ç"; |
| | | return (sheets, fileName); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Checks the create or update dto asynchronous. |
| | | /// </summary> |
| | | /// <param name="input">The input.</param> |
| | | protected Task CheckCreateOrUpdateDtoAsync(SampleCreateOrUpdateDtoBase input) |
| | | { |
| | | Check.NotNull(input, nameof(input)); |
| | | Check.NotNullOrWhiteSpace(input.Code, "ç¼å·", SampleConsts.MaxCodeLength); |
| | | Check.NotNullOrWhiteSpace(input.Name, "åç§°", SampleConsts.MaxNameLength); |
| | | Check.Length(input.Remark, "夿³¨", SampleConsts.MaxRemarkLength); |
| | | return Task.CompletedTask; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using AutoMapper; |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | using Volo.Abp.ObjectExtending; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.MapperProfiles; |
| | | |
| | | /// <summary> |
| | | /// AutoMapperé
ç½® |
| | | /// </summary> |
| | | /// <seealso cref="AutoMapper.Profile" /> |
| | | public class SampleAutoMapperProfile : Profile |
| | | { |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="SampleAutoMapperProfile"/> class. |
| | | /// </summary> |
| | | public SampleAutoMapperProfile() |
| | | { |
| | | /* You can configure your AutoMapper mapping configuration here. |
| | | * Alternatively, you can split your mapping configurations |
| | | * into multiple profile classes for a better organization. */ |
| | | CreateMap<Sample, SampleDto>(MemberList.None).MapExtraProperties(MappingPropertyDefinitionChecks.None); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <Import Project="../../common.props" /> |
| | | <Import Project="../../configureawait.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> |
| | | <GenerateDocumentationFile>True</GenerateDocumentationFile> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="KissUtil" Version="1.0.1" /> |
| | | <PackageReference Include="Volo.Abp.Localization" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.Validation" Version="$(ABPPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <EmbeddedResource Include="Localization\WareCmsUtilityApi\*.json" /> |
| | | <Content Remove="Localization\WareCmsUtilityApi\*.json" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> |
| | | <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.20" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Shared; |
| | | |
| | | /// <summary> |
| | | /// é误ç¼ç å®ä¹ |
| | | /// </summary> |
| | | public static class CMSPluginDomainErrorCodes |
| | | { |
| | | /// <summary> |
| | | /// The prefix |
| | | /// </summary> |
| | | private const string Prefix = "CMS.Plugin.WareCmsUtilityApi:"; |
| | | |
| | | /* You can add your business exception error codes here, as constants */ |
| | | |
| | | public const string NameAlreadyExists = Prefix + nameof(NameAlreadyExists); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Localization; |
| | | using Volo.Abp.Localization; |
| | | using Volo.Abp.Modularity; |
| | | using Volo.Abp.Validation; |
| | | using Volo.Abp.Validation.Localization; |
| | | using Volo.Abp.VirtualFileSystem; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Shared; |
| | | |
| | | /// <summary> |
| | | /// é¢åå
±äº«æ¨¡å |
| | | /// </summary> |
| | | [DependsOn(typeof(AbpLocalizationModule), |
| | | typeof(AbpValidationModule))] |
| | | public class CMSPluginDomainSharedModule : AbpModule |
| | | { |
| | | /// <inheritdoc /> |
| | | public override void PreConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | CMSPluginModuleExtensionConfigurator.Configure(); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | Configure<AbpVirtualFileSystemOptions>(options => |
| | | { |
| | | options.FileSets.AddEmbedded<CMSPluginDomainSharedModule>(); |
| | | }); |
| | | |
| | | Configure<AbpLocalizationOptions>(options => |
| | | { |
| | | options.Resources |
| | | .Add<WareCmsUtilityApiResource>("en") |
| | | .AddBaseTypes(typeof(AbpValidationResource)) |
| | | .AddVirtualJson("/Localization/WareCmsUtilityApi"); |
| | | |
| | | options.DefaultResourceType = typeof(WareCmsUtilityApiResource); |
| | | }); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Threading; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Shared; |
| | | |
| | | /// <summary> |
| | | /// æ¨¡åæ©å±é
ç½®å¨ |
| | | /// </summary> |
| | | public static class CMSPluginModuleExtensionConfigurator |
| | | { |
| | | private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
| | | |
| | | /// <summary> |
| | | /// Configures this instance. |
| | | /// </summary> |
| | | public static void Configure() |
| | | { |
| | | OneTimeRunner.Run(() => |
| | | { |
| | | ConfigureExistingProperties(); |
| | | ConfigureExtraProperties(); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Configures the existing properties. |
| | | /// </summary> |
| | | private static void ConfigureExistingProperties() |
| | | { |
| | | /* You can change max lengths for properties of the |
| | | * entities defined in the modules used by your application. |
| | | * |
| | | * Example: Change user and role name max lengths |
| | | |
| | | IdentityUserConsts.MaxNameLength = 99; |
| | | IdentityRoleConsts.MaxNameLength = 99; |
| | | |
| | | * Notice: It is not suggested to change property lengths |
| | | * unless you really need it. Go with the standard values wherever possible. |
| | | * |
| | | * If you are using EF Core, you will need to run the add-migration command after your changes. |
| | | */ |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Configures the extra properties. |
| | | /// </summary> |
| | | private static void ConfigureExtraProperties() |
| | | { |
| | | /* You can configure extra properties for the |
| | | * entities defined in the modules used by your application. |
| | | * |
| | | * This class can be used to define these extra properties |
| | | * with a high level, easy to use API. |
| | | * |
| | | * Example: Add a new property to the user entity of the identity module |
| | | |
| | | ObjectExtensionManager.Instance.Modules() |
| | | .ConfigureIdentity(identity => |
| | | { |
| | | identity.ConfigureUser(user => |
| | | { |
| | | user.AddOrUpdateProperty<string>( //property type: string |
| | | "SocialSecurityNumber", //property name |
| | | property => |
| | | { |
| | | //validation rules |
| | | property.Attributes.Add(new RequiredAttribute()); |
| | | property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4}); |
| | | |
| | | property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = true; |
| | | |
| | | //...other configurations for this property |
| | | } |
| | | ); |
| | | }); |
| | | }); |
| | | |
| | | * See the documentation for more: |
| | | * https://docs.abp.io/en/abp/latest/Module-Entity-Extensions |
| | | */ |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System.ComponentModel; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Enums |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApiç¶æ |
| | | /// </summary> |
| | | public enum WareCmsUtilityApiStatus : byte |
| | | { |
| | | /// <summary> |
| | | /// æªæ§è¡ |
| | | /// </summary> |
| | | [Description("æªæ§è¡")] |
| | | Initial = 0, |
| | | |
| | | /// <summary> |
| | | /// æ§è¡ä¸ |
| | | /// </summary> |
| | | [Description("æ§è¡ä¸")] |
| | | Excuting = 1, |
| | | |
| | | /// <summary> |
| | | /// 已宿 |
| | | /// </summary> |
| | | [Description("已宿")] |
| | | Completed = 4, |
| | | |
| | | /// <summary> |
| | | /// 已强å¶å®æ |
| | | /// </summary> |
| | | [Description("已宿")] |
| | | Finished = 5, |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "culture": "en", |
| | | "texts": { |
| | | "DisplayName:SCMS.AppSettings.WareCmsUtilityApi.PluginState": "WareCmsUtilityApi plugin state", |
| | | "CMS.Plugin.WareCmsUtilityApi:NameAlreadyExists": "The '{0}' name already exists, please re-enter it !" |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "culture": "zh-Hans", |
| | | "texts": { |
| | | "DisplayName:SCMS.AppSettings.WareCmsUtilityApi.PluginState": "WareCmsUtilityApi æä»¶ç¶æ", |
| | | "CMS.Plugin.WareCmsUtilityApi:NameAlreadyExists": "该'{0}'åç§°å·²åå¨ï¼è¯·éæ°è¾å
¥ï¼" |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Localization; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Localization; |
| | | |
| | | /// <summary> |
| | | /// WareCmsUtilityApiæ¬å°åèµæº |
| | | /// </summary> |
| | | [LocalizationResourceName("WareCmsUtilityApi")] |
| | | public class WareCmsUtilityApiResource |
| | | { |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Samples; |
| | | |
| | | /// <summary> |
| | | /// Sample常éå®ä¹ |
| | | /// </summary> |
| | | public static class SampleConsts |
| | | { |
| | | public const string CloneTag = "_坿¬"; |
| | | public static int MaxCodeLength { get; set; } = 64; |
| | | public static int MaxNameLength { get; set; } = 64; |
| | | public static int MaxRemarkLength { get; set; } = 256; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Samples; |
| | | |
| | | /// <summary> |
| | | /// Sampleäºä»¶åæ°å¯¹è±¡ |
| | | /// </summary> |
| | | [Serializable] |
| | | public class SampleEto |
| | | { |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="SampleEto"/> class. |
| | | /// </summary> |
| | | /// <param name="name">The name.</param> |
| | | public SampleEto(string name) |
| | | { |
| | | Name = name; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åç§° |
| | | /// </summary> |
| | | public string Name { get; } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <Import Project="../../common.props" /> |
| | | <Import Project="../../configureawait.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.Settings" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.Caching" Version="$(ABPPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.Abstractions\CMS.Plugin.WareCmsUtilityApi.Abstractions.csproj" /> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.Domain.Shared\CMS.Plugin.WareCmsUtilityApi.Domain.Shared.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | |
| | | /// <summary> |
| | | /// æ°æ®åºå±æ§å®ä¹ |
| | | /// </summary> |
| | | public static class CMSPluginDbProperties |
| | | { |
| | | /// <summary> |
| | | /// Gets or sets the database table prefix. |
| | | /// </summary> |
| | | public static string DbTablePrefix { get; set; } = "SCMS"; |
| | | |
| | | /// <summary> |
| | | /// Gets or sets the database schema. |
| | | /// </summary> |
| | | public static string DbSchema { get; set; } |
| | | |
| | | /// <summary> |
| | | /// The connection string name |
| | | /// </summary> |
| | | public const string ConnectionStringName = "WareCmsUtilityApi"; |
| | | |
| | | /// <summary> |
| | | /// The migrations history table |
| | | /// </summary> |
| | | public const string MigrationsHistoryTable = "__EFMigrationsHistoryForWareCmsUtilityApi"; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared; |
| | | using Volo.Abp.Caching; |
| | | using Volo.Abp.Domain; |
| | | using Volo.Abp.Modularity; |
| | | using Volo.Abp.Settings; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | |
| | | /// <summary> |
| | | /// é¢å模å |
| | | /// </summary> |
| | | [DependsOn( |
| | | typeof(CMSPluginDomainSharedModule), |
| | | typeof(AbpSettingsModule), |
| | | typeof(AbpDddDomainModule), |
| | | typeof(AbpCachingModule) |
| | | )] |
| | | public class CMSPluginDomainModule : AbpModule |
| | | { |
| | | /// <inheritdoc /> |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Microsoft.Extensions.Logging; |
| | | using System.Diagnostics; |
| | | using System.Runtime.InteropServices; |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.DependencyInjection; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Data; |
| | | |
| | | /// <summary> |
| | | /// æ°æ®åºè¿ç§»æå¡ |
| | | /// </summary> |
| | | public class CMSPluginDbMigrationService : ITransientDependency |
| | | { |
| | | private readonly IDataSeeder _dataSeeder; |
| | | private readonly IEnumerable<ICMSPluginDbSchemaMigrator> _dbSchemaMigrators; |
| | | private readonly ILogger<CMSPluginDbMigrationService> _logger; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CMSPluginDbMigrationService"/> class. |
| | | /// </summary> |
| | | /// <param name="dataSeeder">The data seeder.</param> |
| | | /// <param name="dbSchemaMigrators">The database schema migrators.</param> |
| | | /// <param name="logger">The logger.</param> |
| | | public CMSPluginDbMigrationService(IDataSeeder dataSeeder, |
| | | IEnumerable<ICMSPluginDbSchemaMigrator> dbSchemaMigrators, ILogger<CMSPluginDbMigrationService> logger) |
| | | { |
| | | _dataSeeder = dataSeeder; |
| | | _dbSchemaMigrators = dbSchemaMigrators; |
| | | _logger = logger; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Migrates the asynchronous. |
| | | /// </summary> |
| | | public async Task MigrateAsync() |
| | | { |
| | | var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
| | | |
| | | if (initialMigrationAdded) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | _logger.LogDebug("Started database migrations..."); |
| | | |
| | | await MigrateDatabaseSchemaAsync(); |
| | | await SeedDataAsync(); |
| | | |
| | | _logger.LogDebug($"Successfully completed host database migrations."); |
| | | _logger.LogDebug("You can safely end this process..."); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Migrates the database schema asynchronous. |
| | | /// </summary> |
| | | private async Task MigrateDatabaseSchemaAsync() |
| | | { |
| | | _logger.LogDebug($"Migrating schema for database..."); |
| | | |
| | | foreach (var migrator in _dbSchemaMigrators) |
| | | { |
| | | await migrator.MigrateAsync(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Seeds the data asynchronous. |
| | | /// </summary> |
| | | private async Task SeedDataAsync() |
| | | { |
| | | _logger.LogDebug($"Executing database seed..."); |
| | | |
| | | await _dataSeeder.SeedAsync(new DataSeedContext().WithProperty(CMSPluginDbProperties.ConnectionStringName, CMSPluginDbProperties.ConnectionStringName)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Adds the initial migration if not exist. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private bool AddInitialMigrationIfNotExist() |
| | | { |
| | | try |
| | | { |
| | | if (!DbMigrationsProjectExists()) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | try |
| | | { |
| | | if (!MigrationsFolderExists()) |
| | | { |
| | | AddInitialMigration(); |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | _logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Databases the migrations project exists. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private bool DbMigrationsProjectExists() |
| | | { |
| | | var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
| | | |
| | | return dbMigrationsProjectFolder != null; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Migrationses the folder exists. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private bool MigrationsFolderExists() |
| | | { |
| | | var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
| | | |
| | | return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Adds the initial migration. |
| | | /// </summary> |
| | | /// <exception cref="System.Exception">Couldn't run ABP CLI...</exception> |
| | | private void AddInitialMigration() |
| | | { |
| | | _logger.LogDebug("Creating initial migration..."); |
| | | |
| | | string argumentPrefix; |
| | | string fileName; |
| | | |
| | | if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
| | | { |
| | | argumentPrefix = "-c"; |
| | | fileName = "/bin/bash"; |
| | | } |
| | | else |
| | | { |
| | | argumentPrefix = "/C"; |
| | | fileName = "cmd.exe"; |
| | | } |
| | | |
| | | var procStartInfo = new ProcessStartInfo(fileName, |
| | | $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\"\"" |
| | | ); |
| | | |
| | | try |
| | | { |
| | | Process.Start(procStartInfo); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw new Exception("Couldn't run ABP CLI..."); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Gets the entity framework core project folder path. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | /// <exception cref="System.Exception">Solution folder not found!</exception> |
| | | private string GetEntityFrameworkCoreProjectFolderPath() |
| | | { |
| | | var slnDirectoryPath = GetSolutionDirectoryPath(); |
| | | |
| | | if (slnDirectoryPath == null) |
| | | { |
| | | throw new Exception("Solution folder not found!"); |
| | | } |
| | | |
| | | var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src"); |
| | | |
| | | return Directory.GetDirectories(srcDirectoryPath) |
| | | .FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore")); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Gets the solution directory path. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private string GetSolutionDirectoryPath() |
| | | { |
| | | var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
| | | |
| | | while (Directory.GetParent(currentDirectory.FullName) != null) |
| | | { |
| | | currentDirectory = Directory.GetParent(currentDirectory.FullName); |
| | | |
| | | if (Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
| | | { |
| | | return currentDirectory.FullName; |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System.Data; |
| | | using Volo.Abp.DependencyInjection; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Data; |
| | | |
| | | /// <summary> |
| | | /// Dapperä»å¨ |
| | | /// </summary> |
| | | public interface ICMSPluginDapperRepository : ITransientDependency |
| | | { |
| | | /// <summary> |
| | | /// Gets the database connection asynchronous. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | Task<IDbConnection> GetDbConnectionAsync(); |
| | | |
| | | /// <summary> |
| | | /// Gets the database transaction asynchronous. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | Task<IDbTransaction> GetDbTransactionAsync(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Data; |
| | | |
| | | /// <summary> |
| | | /// æ°æ®åºæ¶æè¿ç§»å¨ |
| | | /// </summary> |
| | | public interface ICMSPluginDbSchemaMigrator |
| | | { |
| | | /// <summary> |
| | | /// Migrates the asynchronous. |
| | | /// </summary> |
| | | Task MigrateAsync(); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.DependencyInjection; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Data; |
| | | |
| | | /// <summary> |
| | | /// This is used if database provider does't define |
| | | /// ICMSDbSchemaMigrator implementation. |
| | | /// </summary> |
| | | public class NullCMSPluginDbSchemaMigrator : ICMSPluginDbSchemaMigrator, ITransientDependency |
| | | { |
| | | /// <inheritdoc /> |
| | | public Task MigrateAsync() |
| | | { |
| | | return Task.CompletedTask; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Samples; |
| | | using Volo.Abp.DependencyInjection; |
| | | using Volo.Abp.EventBus.Distributed; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.EventHandlers; |
| | | |
| | | /// <summary> |
| | | /// Sampleäºä»¶å¤çç¨åº |
| | | /// </summary> |
| | | public class SampleEventHandler : IDistributedEventHandler<SampleEto>, ITransientDependency |
| | | { |
| | | /// <inheritdoc /> |
| | | public Task HandleEventAsync(SampleEto eventData) |
| | | { |
| | | return Task.CompletedTask; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Domain.Repositories; |
| | | using Volo.Abp.Specifications; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | |
| | | /// <summary> |
| | | /// Sampleä»å¨ |
| | | /// </summary> |
| | | public interface ISampleRepository : IBasicRepository<Sample, Guid> |
| | | { |
| | | /// <summary> |
| | | /// Finds the by name asynchronous. |
| | | /// </summary> |
| | | /// <param name="name">The name.</param> |
| | | /// <param name="cancellationToken">The cancellation token.</param> |
| | | /// <returns></returns> |
| | | Task<Sample> FindByNameAsync(string name, CancellationToken cancellationToken = default); |
| | | |
| | | /// <summary> |
| | | /// Names the exist asynchronous. |
| | | /// </summary> |
| | | /// <param name="name">The name.</param> |
| | | /// <param name="id">The identifier.</param> |
| | | /// <returns></returns> |
| | | Task<bool> NameExistAsync(string name, Guid? id = null); |
| | | |
| | | /// <summary> |
| | | /// Gets the maximum sort asynchronous. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | Task<int> GetMaxSortAsync(); |
| | | |
| | | /// <summary> |
| | | /// Gets the list asynchronous. |
| | | /// </summary> |
| | | /// <param name="sorting">The sorting.</param> |
| | | /// <param name="maxResultCount">The maximum result count.</param> |
| | | /// <param name="skipCount">The skip count.</param> |
| | | /// <param name="filter">The filter.</param> |
| | | /// <param name="specification">The specification.</param> |
| | | /// <param name="includeDetails">if set to <c>true</c> [include details].</param> |
| | | /// <param name="cancellationToken">The cancellation token.</param> |
| | | /// <returns></returns> |
| | | Task<List<Sample>> GetListAsync(string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, string filter = null, Specification<Sample> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default); |
| | | |
| | | /// <summary> |
| | | /// Gets the count asynchronous. |
| | | /// </summary> |
| | | /// <param name="filter">The filter.</param> |
| | | /// <param name="specification">The specification.</param> |
| | | /// <param name="cancellationToken">The cancellation token.</param> |
| | | /// <returns></returns> |
| | | Task<long> GetCountAsync(string filter = null, Specification<Sample> specification = null, CancellationToken cancellationToken = default); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Samples; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Domain.Entities.Auditing; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Samples |
| | | { |
| | | /// <summary> |
| | | /// Sample |
| | | /// </summary> |
| | | public class Sample : FullAuditedAggregateRoot<Guid> |
| | | { |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="Sample"/> class. |
| | | /// </summary> |
| | | protected Sample() |
| | | { |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="Sample"/> class. |
| | | /// </summary> |
| | | /// <param name="id">The identifier.</param> |
| | | /// <param name="code">The code.</param> |
| | | /// <param name="name">The name.</param> |
| | | /// <param name="sort">The sort.</param> |
| | | /// <param name="remark">The remark.</param> |
| | | public Sample(Guid id, string code, string name, int sort = 0, string remark = null) : base(id) |
| | | { |
| | | Code = Check.NotNullOrWhiteSpace(code, "ç¼å·", SampleConsts.MaxCodeLength); |
| | | Name = Check.NotNullOrWhiteSpace(name, "åç§°", SampleConsts.MaxNameLength); |
| | | Sort = sort; |
| | | Remark = Check.Length(remark, "夿³¨", SampleConsts.MaxRemarkLength); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ç¼å· |
| | | /// </summary> |
| | | public virtual string Code { get; protected set; } |
| | | |
| | | /// <summary> |
| | | /// åç§° |
| | | /// </summary> |
| | | public virtual string Name { get; protected set; } |
| | | |
| | | /// <summary> |
| | | /// æåº |
| | | /// </summary> |
| | | public virtual int Sort { get; protected set; } |
| | | |
| | | /// <summary> |
| | | /// 夿³¨ |
| | | /// </summary> |
| | | public virtual string Remark { get; protected set; } |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦ç¦ç¨ |
| | | /// </summary> |
| | | public virtual bool? IsDisabled { get; protected set; } |
| | | |
| | | /// <summary> |
| | | /// Updates the specified code. |
| | | /// </summary> |
| | | /// <param name="code">The code.</param> |
| | | /// <param name="name">The name.</param> |
| | | /// <param name="remark">The remark.</param> |
| | | public virtual void Update(string code, string name, string remark = null, bool? isDisabled = null) |
| | | { |
| | | Code = Check.NotNullOrWhiteSpace(code, "ç¼å·", SampleConsts.MaxCodeLength); |
| | | Name = Check.NotNullOrWhiteSpace(name, "åç§°", SampleConsts.MaxNameLength); |
| | | Remark = Check.Length(remark, "夿³¨", SampleConsts.MaxRemarkLength); |
| | | IsDisabled = isDisabled ?? IsDisabled; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Adjusts the sort. |
| | | /// </summary> |
| | | /// <param name="sort">The sort.</param> |
| | | public void AdjustSort(int sort) |
| | | { |
| | | Sort = sort; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Clones the specified create. |
| | | /// </summary> |
| | | /// <param name="create">The create.</param> |
| | | /// <param name="name">The name.</param> |
| | | /// <param name="i">The i.</param> |
| | | /// <returns></returns> |
| | | public Sample Clone(Guid create, string name, int i) |
| | | { |
| | | return new Sample(create, Code, name, i, Remark); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.DependencyInjection; |
| | | using Volo.Abp.Guids; |
| | | using Volo.Abp.Uow; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Samples |
| | | { |
| | | /// <summary> |
| | | /// Sampleç§åæ°æ®æä¾ç¨åº |
| | | /// </summary> |
| | | public class SampleDataSeedContributor : IDataSeedContributor, ITransientDependency |
| | | { |
| | | private readonly IUnitOfWorkManager _unitOfWorkManager; |
| | | private readonly ISampleRepository _sampleRepository; |
| | | private readonly IGuidGenerator _guidGenerator; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="SampleDataSeedContributor"/> class. |
| | | /// </summary> |
| | | /// <param name="unitOfWorkManager">The unit of work manager.</param> |
| | | /// <param name="guidGenerator">The unique identifier generator.</param> |
| | | /// <param name="sampleRepository">The work section repository.</param> |
| | | public SampleDataSeedContributor(IUnitOfWorkManager unitOfWorkManager, IGuidGenerator guidGenerator, ISampleRepository sampleRepository) |
| | | { |
| | | _unitOfWorkManager = unitOfWorkManager; |
| | | _sampleRepository = sampleRepository; |
| | | _guidGenerator = guidGenerator; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task SeedAsync(DataSeedContext context) |
| | | { |
| | | if (context.Properties.ContainsKey(CMSPluginDbProperties.ConnectionStringName) && context.Properties[CMSPluginDbProperties.ConnectionStringName]?.ToString() == CMSPluginDbProperties.ConnectionStringName) |
| | | { |
| | | try |
| | | { |
| | | //using var unitofWork = _unitOfWorkManager.Begin(requiresNew: true); |
| | | //await unitofWork.SaveChangesAsync(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.Message); |
| | | } |
| | | } |
| | | |
| | | if (context.Properties.ContainsKey("SeedTestData") && context.Properties["SeedTestData"]?.ToString() == "SeedTestData") |
| | | { |
| | | try |
| | | { |
| | | await SeedSampleDataAsync(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | Console.WriteLine(e.Message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Seeds the work section data asynchronous. |
| | | /// </summary> |
| | | private async Task SeedSampleDataAsync() |
| | | { |
| | | using var unitofWork = _unitOfWorkManager.Begin(requiresNew: true); |
| | | if (await _sampleRepository.GetCountAsync() == 0) |
| | | { |
| | | var Samples = new List<Sample>(); |
| | | for (int i = 1; i <= 80; i++) |
| | | { |
| | | var sample = new Sample(_guidGenerator.Create(), $"Sample_Code{i}", $"Sample_Name{i}", i, $"Sample_Remark{i}"); |
| | | Samples.Add(sample); |
| | | } |
| | | |
| | | await _sampleRepository.InsertManyAsync(Samples); |
| | | await unitofWork.SaveChangesAsync(); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System.Linq.Expressions; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Samples |
| | | { |
| | | /// <summary> |
| | | /// Sampleè§çº¦ |
| | | /// </summary> |
| | | public class SampleSpecification : Volo.Abp.Specifications.Specification<Sample> |
| | | { |
| | | private readonly string _name; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="SampleSpecification"/> class. |
| | | /// </summary> |
| | | public SampleSpecification() |
| | | { |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="SampleSpecification"/> class. |
| | | /// </summary> |
| | | /// <param name="name">The name.</param> |
| | | public SampleSpecification(string name = null) |
| | | { |
| | | _name = name; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override Expression<Func<Sample, bool>> ToExpression() |
| | | { |
| | | Expression<Func<Sample, bool>> expression = c => 1 == 1; |
| | | |
| | | if (_name != null) |
| | | { |
| | | expression = expression.And(c => c.Name == _name); |
| | | } |
| | | |
| | | return expression; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Abstractions; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Localization; |
| | | using Volo.Abp.Localization; |
| | | using Volo.Abp.Settings; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Settings; |
| | | |
| | | /// <summary> |
| | | /// 设置å®ä¹æä¾ç¨åº |
| | | /// </summary> |
| | | public class CMSPluginSettingDefinitionProvider : SettingDefinitionProvider |
| | | { |
| | | public override void Define(ISettingDefinitionContext context) |
| | | { |
| | | context.Add(new SettingDefinition(CMSPluginWareCmsUtilityApiSettings.PluginState, "1", L($"DisplayName:{CMSPluginWareCmsUtilityApiSettings.PluginState}"), isInherited: true)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ls the specified name. |
| | | /// </summary> |
| | | /// <param name="name">The name.</param> |
| | | /// <returns></returns> |
| | | private static LocalizableString L(string name) |
| | | { |
| | | return LocalizableString.Create<WareCmsUtilityApiResource>(name); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <Import Project="../../common.props" /> |
| | | <Import Project="../../configureawait.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Volo.Abp.Dapper" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="$(ABPPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.Domain\CMS.Plugin.WareCmsUtilityApi.Domain.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Data; |
| | | using Volo.Abp.Domain.Repositories.Dapper; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | |
| | | /// <inheritdoc /> |
| | | public class CMSPluginDapperRepository : DapperRepository<ICMSPluginDbContext>, ICMSPluginDapperRepository |
| | | { |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CMSPluginDapperRepository"/> class. |
| | | /// </summary> |
| | | /// <param name="dbContextProvider">The database context provider.</param> |
| | | public CMSPluginDapperRepository(IDbContextProvider<ICMSPluginDbContext> dbContextProvider) |
| | | : base(dbContextProvider) |
| | | { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Data; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Logging; |
| | | using Volo.Abp.DependencyInjection; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | |
| | | /// <inheritdoc /> |
| | | public class CMSPluginDbSchemaMigrator : ICMSPluginDbSchemaMigrator, ITransientDependency |
| | | { |
| | | private readonly IServiceProvider _serviceProvider; |
| | | private readonly ILogger<CMSPluginDbSchemaMigrator> _logger; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CMSPluginDbSchemaMigrator"/> class. |
| | | /// </summary> |
| | | /// <param name="serviceProvider">The service provider.</param> |
| | | public CMSPluginDbSchemaMigrator(IServiceProvider serviceProvider, ILogger<CMSPluginDbSchemaMigrator> logger) |
| | | { |
| | | _serviceProvider = serviceProvider; |
| | | _logger = logger; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task MigrateAsync() |
| | | { |
| | | /* We intentionally resolving the CMSDbContext |
| | | * from IServiceProvider (instead of directly injecting it) |
| | | * to properly get the connection string of the current tenant in the |
| | | * current scope. |
| | | */ |
| | | var database = _serviceProvider.GetRequiredService<ICMSPluginDbContext>().Database; |
| | | _logger.LogInformation($"Start database {database.GetDbConnection().Database} migrate"); |
| | | await database.MigrateAsync(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared; |
| | | using Volo.Abp.Threading; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | |
| | | /// <summary> |
| | | /// EfCoreå®ä½æ©å± |
| | | /// </summary> |
| | | public static class CMSPluginEfCoreEntityExtensionMappings |
| | | { |
| | | private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); |
| | | |
| | | /// <summary> |
| | | /// Configures this instance. |
| | | /// </summary> |
| | | public static void Configure() |
| | | { |
| | | CMSPluginModuleExtensionConfigurator.Configure(); |
| | | |
| | | OneTimeRunner.Run(() => |
| | | { |
| | | /* You can configure extra properties for the |
| | | * entities defined in the modules used by your application. |
| | | * |
| | | * This class can be used to map these extra properties to table fields in the database. |
| | | * |
| | | * USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING. |
| | | * USE CMSModuleExtensionConfigurator CLASS (in the Domain.Shared project) |
| | | * FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES |
| | | * |
| | | * Example: Map a property to a table field: |
| | | |
| | | ObjectExtensionManager.Instance |
| | | .MapEfCoreProperty<Sample, string>( |
| | | "MyProperty", |
| | | (entityBuilder, propertyBuilder) => |
| | | { |
| | | propertyBuilder.HasMaxLength(128); |
| | | } |
| | | ); |
| | | |
| | | * See the documentation for more: |
| | | * https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities |
| | | */ |
| | | }); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | |
| | | /// <summary> |
| | | /// EntityFrameworkCore模å |
| | | /// </summary> |
| | | [DependsOn( |
| | | typeof(CMSPluginDomainModule), |
| | | typeof(AbpEntityFrameworkCoreModule) |
| | | )] |
| | | public class CMSPluginEntityFrameworkCoreModule : AbpModule |
| | | { |
| | | /// <inheritdoc /> |
| | | public override void PreConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | CMSPluginEfCoreEntityExtensionMappings.Configure(); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Shared.Samples; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Volo.Abp; |
| | | using Volo.Abp.EntityFrameworkCore.Modeling; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Extensions; |
| | | |
| | | /// <summary> |
| | | /// EfCoreæ©å± |
| | | /// </summary> |
| | | public static partial class CMSPluginEfCoreExtensions |
| | | { |
| | | /// <summary> |
| | | /// Includes the details. |
| | | /// </summary> |
| | | /// <param name="queryable">The queryable.</param> |
| | | /// <param name="include">if set to <c>true</c> [include].</param> |
| | | /// <returns></returns> |
| | | public static IQueryable<Sample> IncludeDetails(this IQueryable<Sample> queryable, bool include = true) |
| | | { |
| | | if (!include) |
| | | { |
| | | return queryable; |
| | | } |
| | | |
| | | return queryable; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Configures the sample. |
| | | /// </summary> |
| | | /// <param name="builder">The builder.</param> |
| | | public static void ConfigureSample(this ModelBuilder builder) |
| | | { |
| | | Check.NotNull(builder, nameof(builder)); |
| | | |
| | | builder.Entity<Sample>(b => |
| | | { |
| | | //Configure table & schema name |
| | | b.ToTable((CMSPluginDbProperties.DbTablePrefix + "_Samples").ToLower(), CMSPluginDbProperties.DbSchema).HasComment("Sample"); |
| | | |
| | | b.ConfigureByConvention(); |
| | | |
| | | //Properties |
| | | b.Property(x => x.Code).HasMaxLength(SampleConsts.MaxCodeLength).IsRequired().HasComment("ç¼ç "); |
| | | b.Property(x => x.Name).HasMaxLength(SampleConsts.MaxNameLength).IsRequired().HasComment("åç§°"); |
| | | b.Property(x => x.Sort).HasComment("æåº"); |
| | | b.Property(x => x.IsDisabled).IsRequired(false).HasComment("æ¯å¦ç¦ç¨"); |
| | | b.Property(x => x.Remark).HasMaxLength(SampleConsts.MaxRemarkLength).IsRequired(false).HasComment("夿³¨"); |
| | | |
| | | b.HasIndex(u => u.Name); |
| | | |
| | | b.ApplyObjectExtensionMappings(); |
| | | }); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore |
| | | { |
| | | /// <summary> |
| | | /// æ°æ®åºä¸ä¸æ |
| | | /// </summary> |
| | | [ConnectionStringName(CMSPluginDbProperties.ConnectionStringName)] |
| | | public interface ICMSPluginDbContext : IEfCoreDbContext |
| | | { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System.Linq.Dynamic.Core; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Extensions; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | using Volo.Abp.Specifications; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Repositories; |
| | | |
| | | /// <inheritdoc /> |
| | | public class EfCoreSampleRepository : EfCoreRepository<ICMSPluginDbContext, Sample, Guid>, ISampleRepository |
| | | { |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="EfCoreSampleRepository"/> class. |
| | | /// </summary> |
| | | /// <param name="dbContextProvider">The database context provider.</param> |
| | | public EfCoreSampleRepository(IDbContextProvider<ICMSPluginDbContext> dbContextProvider) |
| | | : base(dbContextProvider) |
| | | { |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public virtual async Task<Sample> FindByNameAsync(string name, CancellationToken cancellationToken = default) |
| | | { |
| | | return await (await GetDbSetAsync()) |
| | | .IncludeDetails() |
| | | .OrderBy(t => t.Sort) |
| | | .FirstOrDefaultAsync(t => t.Name == name, GetCancellationToken(cancellationToken)); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<bool> NameExistAsync(string name, Guid? id = null) |
| | | { |
| | | return await (await GetDbSetAsync()).WhereIf(id.HasValue, p => p.Id != id).AnyAsync(x => x.Name == name); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<int> GetMaxSortAsync() |
| | | { |
| | | var hasAny = await (await GetQueryableAsync()).AnyAsync(); |
| | | if (!hasAny) |
| | | { |
| | | return 1; |
| | | } |
| | | |
| | | var sort = await (await GetQueryableAsync()).MaxAsync(x => x.Sort); |
| | | return sort + 1; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<List<Sample>> GetListAsync(string sorting = null, int maxResultCount = int.MaxValue, int skipCount = 0, string filter = null, Specification<Sample> specification = null, bool includeDetails = false, CancellationToken cancellationToken = default) |
| | | { |
| | | specification ??= new SampleSpecification(); |
| | | return await (await GetDbSetAsync()) |
| | | .IncludeDetails(includeDetails) |
| | | .Where(specification.ToExpression()) |
| | | .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.Name.Contains(filter)) |
| | | .OrderBy(sorting.IsNullOrEmpty() ? nameof(Sample.Sort) : sorting) |
| | | .PageBy(skipCount, maxResultCount) |
| | | .ToListAsync(GetCancellationToken(cancellationToken)); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task<long> GetCountAsync(string filter = null, Specification<Sample> specification = null, CancellationToken cancellationToken = default) |
| | | { |
| | | specification ??= new SampleSpecification(); |
| | | return await (await GetQueryableAsync()) |
| | | .Where(specification.ToExpression()) |
| | | .WhereIf(!filter.IsNullOrWhiteSpace(), u => u.Name.Contains(filter)) |
| | | .CountAsync(cancellationToken: GetCancellationToken(cancellationToken)); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override async Task<IQueryable<Sample>> WithDetailsAsync() |
| | | { |
| | | return (await GetQueryableAsync()).IncludeDetails(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | "ConnectionStrings": { |
| | | "Default": "Server=127.0.0.1;Database=CMS.Plugin.WareCmsUtilityApi;User ID=root;Password=123456" |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <Import Project="../../common.props" /> |
| | | <Import Project="../../configureawait.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" Version="$(ABPPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.5"> |
| | | <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> |
| | | <PrivateAssets>compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native</PrivateAssets> |
| | | </PackageReference> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Folder Include="Migrations\" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Extensions; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | using Volo.Abp.EntityFrameworkCore.Modeling; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.MySQL; |
| | | |
| | | /// <summary> |
| | | /// æ°æ®åºä¸ä¸æ |
| | | /// </summary> |
| | | [ConnectionStringName(CMSPluginDbProperties.ConnectionStringName)] |
| | | public class CMSPluginDbContext : AbpDbContext<CMSPluginDbContext>, ICMSPluginDbContext |
| | | { |
| | | /* Add DbSet properties for your Aggregate Roots / Entities here. */ |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CMSPluginDbContext"/> class. |
| | | /// </summary> |
| | | /// <param name="options">The options.</param> |
| | | public CMSPluginDbContext(DbContextOptions<CMSPluginDbContext> options) |
| | | : base(options) |
| | | { |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | protected override void OnModelCreating(ModelBuilder builder) |
| | | { |
| | | base.OnModelCreating(builder); |
| | | |
| | | /* Include modules to your migration db context */ |
| | | |
| | | builder.ConfigureSample(); |
| | | |
| | | /* Configure your own tables/entities inside here */ |
| | | |
| | | //builder.Entity<YourEntity>(b => |
| | | //{ |
| | | // b.ToTable(CMSPluginDbProperties.DbTablePrefix + "YourEntities", CMSPluginDbProperties.DbSchema); |
| | | // b.ConfigureByConvention(); //auto configure for the base class props |
| | | // //... |
| | | //}); |
| | | |
| | | builder.TryConfigureObjectExtensions<CMSPluginDbContext>(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore.Design; |
| | | using Microsoft.Extensions.Configuration; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.MySQL; |
| | | |
| | | /// <summary> |
| | | /// This class is needed for EF Core console commands |
| | | /// (like Add-Migration and Update-Database commands) |
| | | /// </summary> |
| | | public class CMSPluginDbContextFactory : IDesignTimeDbContextFactory<CMSPluginDbContext> |
| | | { |
| | | /// <summary> |
| | | /// Creates a new instance of a derived context. |
| | | /// </summary> |
| | | /// <param name="args">Arguments provided by the design-time service.</param> |
| | | public CMSPluginDbContext CreateDbContext(string[] args) |
| | | { |
| | | CMSPluginEfCoreEntityExtensionMappings.Configure(); |
| | | |
| | | var configuration = BuildConfiguration(); |
| | | |
| | | var builder = new DbContextOptionsBuilder<CMSPluginDbContext>() |
| | | .UseMySql(configuration.GetConnectionString("Default"), MySqlServerVersion.LatestSupportedServerVersion, x => x.MigrationsHistoryTable(CMSPluginDbProperties.MigrationsHistoryTable, CMSPluginDbProperties.DbSchema)); |
| | | |
| | | return new CMSPluginDbContext(builder.Options); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Builds the configuration. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private static IConfigurationRoot BuildConfiguration() |
| | | { |
| | | var builder = new ConfigurationBuilder() |
| | | .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore/")) |
| | | .AddJsonFile("appsettings.json", optional: false); |
| | | |
| | | return builder.Build(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.MySQL; |
| | | |
| | | /// <summary> |
| | | /// EntityFrameworkCore模å |
| | | /// </summary> |
| | | [DependsOn(typeof(CMSPluginEntityFrameworkCoreModule))] |
| | | public class CMSPluginMySQLModule : AbpModule |
| | | { |
| | | /// <inheritdoc /> |
| | | public override void PreConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | CMSPluginEfCoreEntityExtensionMappings.Configure(); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | context.Services.AddAbpDbContext<CMSPluginDbContext>(options => |
| | | { |
| | | /* Remove "includeAllEntities: true" to create |
| | | * default repositories only for aggregate roots */ |
| | | //options.AddDefaultRepositories(includeAllEntities: true); |
| | | }); |
| | | |
| | | Configure<AbpDbContextOptions>(options => |
| | | { |
| | | /* The main point to change your DBMS. |
| | | * See also CMSMigrationsDbContextFactory for EF Core tooling. */ |
| | | options.UseMySQL(x => |
| | | { |
| | | x.MigrationsHistoryTable(CMSPluginDbProperties.MigrationsHistoryTable, CMSPluginDbProperties.DbSchema); |
| | | //x.EnableRetryOnFailure(); |
| | | }); |
| | | }); |
| | | } |
| | | } |
copy from "Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/UtilityApi/src/CMS.Plugin.HIAWms.PostgreSql/Scripts/UpdateMigrations.bat"
copy to "Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/WareCmsUtilityApi/server/src/CMS.Plugin.WareCmsUtilityApi.MySQL/Scripts/UpdateMigrations.bat"
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <Import Project="../../common.props" /> |
| | | <Import Project="../../configureawait.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" Version="$(ABPPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.5"> |
| | | <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> |
| | | <PrivateAssets>compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native</PrivateAssets> |
| | | </PackageReference> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Folder Include="Migrations\" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Extensions; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | using Volo.Abp.EntityFrameworkCore.Modeling; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.PostgreSql; |
| | | |
| | | /// <summary> |
| | | /// æ°æ®åºä¸ä¸æ |
| | | /// </summary> |
| | | [ConnectionStringName(CMSPluginDbProperties.ConnectionStringName)] |
| | | public class CMSPluginDbContext : AbpDbContext<CMSPluginDbContext>, ICMSPluginDbContext |
| | | { |
| | | /* Add DbSet properties for your Aggregate Roots / Entities here. */ |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CMSPluginDbContext"/> class. |
| | | /// </summary> |
| | | /// <param name="options">The options.</param> |
| | | public CMSPluginDbContext(DbContextOptions<CMSPluginDbContext> options) |
| | | : base(options) |
| | | { |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | protected override void OnModelCreating(ModelBuilder builder) |
| | | { |
| | | base.OnModelCreating(builder); |
| | | |
| | | /* Include modules to your migration db context */ |
| | | |
| | | builder.ConfigureSample(); |
| | | |
| | | /* Configure your own tables/entities inside here */ |
| | | |
| | | //builder.Entity<YourEntity>(b => |
| | | //{ |
| | | // b.ToTable(CMSPluginDbProperties.DbTablePrefix + "YourEntities", CMSPluginDbProperties.DbSchema); |
| | | // b.ConfigureByConvention(); //auto configure for the base class props |
| | | // //... |
| | | //}); |
| | | |
| | | builder.TryConfigureObjectExtensions<CMSPluginDbContext>(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore.Design; |
| | | using Microsoft.Extensions.Configuration; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.PostgreSql; |
| | | |
| | | /// <summary> |
| | | /// This class is needed for EF Core console commands |
| | | /// (like Add-Migration and Update-Database commands) |
| | | /// </summary> |
| | | public class CMSPluginDbContextFactory : IDesignTimeDbContextFactory<CMSPluginDbContext> |
| | | { |
| | | /// <summary> |
| | | /// Creates a new instance of a derived context. |
| | | /// </summary> |
| | | /// <param name="args">Arguments provided by the design-time service.</param> |
| | | public CMSPluginDbContext CreateDbContext(string[] args) |
| | | { |
| | | CMSPluginEfCoreEntityExtensionMappings.Configure(); |
| | | |
| | | var configuration = BuildConfiguration(); |
| | | |
| | | var builder = new DbContextOptionsBuilder<CMSPluginDbContext>() |
| | | .UseNpgsql(configuration.GetConnectionString("Default"), x => x.MigrationsHistoryTable(CMSPluginDbProperties.MigrationsHistoryTable, CMSPluginDbProperties.DbSchema)); |
| | | |
| | | return new CMSPluginDbContext(builder.Options); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Builds the configuration. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private static IConfigurationRoot BuildConfiguration() |
| | | { |
| | | var builder = new ConfigurationBuilder() |
| | | .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore/")) |
| | | .AddJsonFile("appsettings.json", optional: false); |
| | | |
| | | return builder.Build(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.PostgreSql; |
| | | |
| | | /// <summary> |
| | | /// EntityFrameworkCore模å |
| | | /// </summary> |
| | | [DependsOn(typeof(CMSPluginEntityFrameworkCoreModule))] |
| | | public class CMSPluginPostgreSqlModule : AbpModule |
| | | { |
| | | /// <inheritdoc /> |
| | | public override void PreConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | CMSPluginEfCoreEntityExtensionMappings.Configure(); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | context.Services.AddAbpDbContext<CMSPluginDbContext>(options => |
| | | { |
| | | /* Remove "includeAllEntities: true" to create |
| | | * default repositories only for aggregate roots */ |
| | | //options.AddDefaultRepositories(includeAllEntities: true); |
| | | }); |
| | | |
| | | Configure<AbpDbContextOptions>(options => |
| | | { |
| | | /* The main point to change your DBMS. |
| | | * See also CMSMigrationsDbContextFactory for EF Core tooling. */ |
| | | options.UseNpgsql(x => |
| | | { |
| | | x.MigrationsHistoryTable(CMSPluginDbProperties.MigrationsHistoryTable, CMSPluginDbProperties.DbSchema); |
| | | //x.EnableRetryOnFailure(); |
| | | }); |
| | | }); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <Import Project="../../common.props" /> |
| | | <Import Project="../../configureawait.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="$(ABPPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.5"> |
| | | <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> |
| | | <PrivateAssets>compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native</PrivateAssets> |
| | | </PackageReference> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Folder Include="Migrations\" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Extensions; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | using Volo.Abp.EntityFrameworkCore.Modeling; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.SqlServer; |
| | | |
| | | /// <summary> |
| | | /// æ°æ®åºä¸ä¸æ |
| | | /// </summary> |
| | | [ConnectionStringName(CMSPluginDbProperties.ConnectionStringName)] |
| | | public class CMSPluginDbContext : AbpDbContext<CMSPluginDbContext>, ICMSPluginDbContext |
| | | { |
| | | /* Add DbSet properties for your Aggregate Roots / Entities here. */ |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="CMSPluginDbContext"/> class. |
| | | /// </summary> |
| | | /// <param name="options">The options.</param> |
| | | public CMSPluginDbContext(DbContextOptions<CMSPluginDbContext> options) |
| | | : base(options) |
| | | { |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | protected override void OnModelCreating(ModelBuilder builder) |
| | | { |
| | | base.OnModelCreating(builder); |
| | | |
| | | /* Include modules to your migration db context */ |
| | | |
| | | builder.ConfigureSample(); |
| | | |
| | | /* Configure your own tables/entities inside here */ |
| | | |
| | | //builder.Entity<YourEntity>(b => |
| | | //{ |
| | | // b.ToTable(CMSPluginDbProperties.DbTablePrefix + "YourEntities", CMSPluginDbProperties.DbSchema); |
| | | // b.ConfigureByConvention(); //auto configure for the base class props |
| | | // //... |
| | | //}); |
| | | |
| | | builder.TryConfigureObjectExtensions<CMSPluginDbContext>(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore.Design; |
| | | using Microsoft.Extensions.Configuration; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.SqlServer; |
| | | |
| | | /// <summary> |
| | | /// This class is needed for EF Core console commands |
| | | /// (like Add-Migration and Update-Database commands) |
| | | /// </summary> |
| | | public class CMSPluginDbContextFactory : IDesignTimeDbContextFactory<CMSPluginDbContext> |
| | | { |
| | | /// <summary> |
| | | /// Creates a new instance of a derived context. |
| | | /// </summary> |
| | | /// <param name="args">Arguments provided by the design-time service.</param> |
| | | public CMSPluginDbContext CreateDbContext(string[] args) |
| | | { |
| | | CMSPluginEfCoreEntityExtensionMappings.Configure(); |
| | | |
| | | var configuration = BuildConfiguration(); |
| | | |
| | | var builder = new DbContextOptionsBuilder<CMSPluginDbContext>() |
| | | .UseSqlServer(configuration.GetConnectionString("Default"), x => x.MigrationsHistoryTable(CMSPluginDbProperties.MigrationsHistoryTable, CMSPluginDbProperties.DbSchema)); |
| | | |
| | | return new CMSPluginDbContext(builder.Options); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Builds the configuration. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private static IConfigurationRoot BuildConfiguration() |
| | | { |
| | | var builder = new ConfigurationBuilder() |
| | | .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore/")) |
| | | .AddJsonFile("appsettings.json", optional: false); |
| | | |
| | | return builder.Build(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.SqlServer; |
| | | |
| | | /// <summary> |
| | | /// EntityFrameworkCore模å |
| | | /// </summary> |
| | | [DependsOn(typeof(CMSPluginEntityFrameworkCoreModule))] |
| | | public class CMSPluginSqlServerModule : AbpModule |
| | | { |
| | | /// <inheritdoc /> |
| | | public override void PreConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | CMSPluginEfCoreEntityExtensionMappings.Configure(); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | context.Services.AddAbpDbContext<CMSPluginDbContext>(options => |
| | | { |
| | | /* Remove "includeAllEntities: true" to create |
| | | * default repositories only for aggregate roots */ |
| | | //options.AddDefaultRepositories(includeAllEntities: true); |
| | | }); |
| | | |
| | | Configure<AbpDbContextOptions>(options => |
| | | { |
| | | /* The main point to change your DBMS. |
| | | * See also CMSMigrationsDbContextFactory for EF Core tooling. */ |
| | | options.UseSqlServer(x => |
| | | { |
| | | x.MigrationsHistoryTable(CMSPluginDbProperties.MigrationsHistoryTable, CMSPluginDbProperties.DbSchema); |
| | | //x.EnableRetryOnFailure(); |
| | | }); |
| | | }); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | using WebApiClientCore.Attributes; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Apis |
| | | { |
| | | /// <summary> |
| | | /// å¤é¨Http APIå¯¹æ¥ // https://webapiclient.github.io/guide/getting-started.html |
| | | /// </summary> |
| | | public interface IWareCmsUtilityApiExternalApi |
| | | { |
| | | /// <summary> |
| | | /// CreateAsync |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpPost("api/v1/warecmsutilityapi/sample")] |
| | | Task<SampleDto> CreateAsync([JsonContent] SampleCreateDto input); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | |
| | | <Import Project="../../common.props" /> |
| | | <Import Project="../../configureawait.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | <EnableDynamicLoading>true</EnableDynamicLoading> |
| | | <ProduceReferenceAssembly>false</ProduceReferenceAssembly> |
| | | <GenerateDocumentationFile>true</GenerateDocumentationFile> |
| | | </PropertyGroup> |
| | | |
| | | <PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))"> |
| | | <CMSRootPath>C:\Program Files\CMS Editor</CMSRootPath> |
| | | <OutputPath>$(CMSRootPath)\plugins\cms.plugin.messuite</OutputPath> |
| | | </PropertyGroup> |
| | | |
| | | <PropertyGroup Condition="$([MSBuild]::IsOSPlatform('OSX'))"> |
| | | <CMSRootPath>/Volumes/SSD/CMS Editor</CMSRootPath> |
| | | <OutputPath>$(CMSRootPath)\plugins\cms.plugin.messuite</OutputPath> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <None Remove="appsettings.json" /> |
| | | <None Remove="Flows\50001_1.pfd" /> |
| | | <None Remove="Flows\FlowInfo.xml" /> |
| | | <None Remove="Resources\Templates\Sampleå¯¼åºæ¨¡æ¿.xlsx" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Content Include="appsettings.json"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </Content> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <EmbeddedResource Include="Resources\Templates\Sampleå¯¼åºæ¨¡æ¿.xlsx"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </EmbeddedResource> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="CMS.Framework.AspNetCore" Version="2.16.1" /> |
| | | <PackageReference Include="CMS.Extensions.Variable" Version="2.16.1" /> |
| | | <PackageReference Include="CMS.Extensions.Data" Version="2.16.1" /> |
| | | <PackageReference Include="CMS.Data.Stressing" Version="2.16.1" /> |
| | | <PackageReference Include="CMS.Extensions.Abp" Version="1.4.0" /> |
| | | <PackageReference Include="WebApiClientCore" Version="2.0.4" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.Application\CMS.Plugin.WareCmsUtilityApi.Application.csproj" /> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.MySQL\CMS.Plugin.WareCmsUtilityApi.MySQL.csproj" /> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.PostgreSql\CMS.Plugin.WareCmsUtilityApi.PostgreSql.csproj" /> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.SqlServer\CMS.Plugin.WareCmsUtilityApi.SqlServer.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <Resource Include="Flows\50001_1.pfd"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </Resource> |
| | | <Resource Include="Flows\FlowInfo.xml"> |
| | | <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
| | | </Resource> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System.Collections; |
| | | using Autofac; |
| | | using CMS.Data.Stressing; |
| | | using CMS.DataPersistence; |
| | | using CMS.DataPersistence.Data; |
| | | using CMS.Extensions.Abp.Autofac.Extensions.DependencyInjection; |
| | | using CMS.Plugin.MesSuite.Abstractions; |
| | | using CMS.Plugin.MesSuite.Abstractions.Consts; |
| | | using CMS.Plugin.WareCmsUtilityApi.Abstractions; |
| | | using CMS.Plugin.WareCmsUtilityApi.Apis; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using CMS.Plugin.WareCmsUtilityApi.ProjectService; |
| | | using CMS.Plugin.WareCmsUtilityApi.Workers; |
| | | using CMS.Plugin.WareCmsUtilityApi.Apis; |
| | | using CMS.Project.Abstractions; |
| | | using Microsoft.AspNetCore.Builder; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Structing.AspNetCore; |
| | | using Structing.Core; |
| | | using Structing.Web; |
| | | using SYC.Plugin; |
| | | using Volo.Abp.BackgroundWorkers; |
| | | using Volo.Abp.DependencyInjection; |
| | | using Volo.Abp.Modularity.PlugIns; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi; |
| | | |
| | | /// <summary> |
| | | /// CMSæä»¶å
¥å£ï¼ä½¿ç¨<see cref="EnableApplicationPartAttribute"/>å°å¯¼å
¥Controller. |
| | | /// </summary> |
| | | [EnableApplicationPart] |
| | | public class CMSPluginEntry : PluginEntry |
| | | { |
| | | private readonly IServiceCollection _service = new ServiceCollection(); |
| | | |
| | | /// <inheritdoc /> |
| | | public override void Register(IRegisteContext context) |
| | | { |
| | | var configuration = context.Features.GetConfiguration(); |
| | | |
| | | // é
ç½®å¤é¨HttpApiï¼ https://webapiclient.github.io/ |
| | | context.Services |
| | | .AddHttpApi<IWareCmsUtilityApiExternalApi>() |
| | | .ConfigureHttpApi(configuration.GetSection(nameof(IWareCmsUtilityApiExternalApi))); |
| | | |
| | | context.Services.TryAddWareCmsUtilityApi(); |
| | | |
| | | context.Services.AddScoped<IProjectRuntimeMigrator, CMSPluginRuntimeMigrator>(); |
| | | context.Services.AddSingleton<IProjectService, WareCmsUtilityApiProjectService>(); |
| | | |
| | | context.Services.AddScoped<IEFDataProvider>(p => |
| | | { |
| | | var cfg = p.GetRequiredService<IDataRuntimeConfig>(); |
| | | return new DefaultEFDataProvider(CMSPluginMesSuiteOptions.DataProviderName, CMSPluginMesSuiteOptions.GetDatabaseSuffix(CMSPluginDbProperties.MigrationsHistoryTable), CMSPluginDbProperties.MigrationsHistoryTable, cfg); |
| | | }); |
| | | |
| | | _service.AddObjectAccessor<IApplicationBuilder>(); |
| | | _service.AddApplication<CMSPluginModule>(options => |
| | | { |
| | | var databaseType = configuration[SectionName.DatabaseType] ?? "mysql"; |
| | | if (KnowsDbCode.IsMysql(databaseType)) |
| | | { |
| | | options.PlugInSources.Add(new TypePlugInSource( |
| | | typeof(MySQL.CMSPluginMySQLModule) |
| | | )); |
| | | } |
| | | else if (KnowsDbCode.IsSqlServer(databaseType)) |
| | | { |
| | | options.PlugInSources.Add(new TypePlugInSource( |
| | | typeof(SqlServer.CMSPluginSqlServerModule) |
| | | )); |
| | | } |
| | | else if (KnowsDbCode.IsPostgreSql(databaseType)) |
| | | { |
| | | options.PlugInSources.Add(new TypePlugInSource( |
| | | typeof(PostgreSql.CMSPluginPostgreSqlModule) |
| | | )); |
| | | } |
| | | }); |
| | | |
| | | base.Register(context); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override void ConfigureContainer(ContainerBuilder builder) |
| | | { |
| | | builder.Populate(_service); |
| | | |
| | | base.ConfigureContainer(builder); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override async Task ReadyAsync(IReadyContext context) |
| | | { |
| | | context.Provider.GetRequiredService<ObjectAccessor<IApplicationBuilder>>().Value = context.Features.GetApplicationBuilder(); |
| | | var app = context.Features.GetApplicationBuilder(); |
| | | await app.InitializeApplicationAsync(); |
| | | |
| | | await base.ReadyAsync(context); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override async Task AfterReadyAsync(IReadyContext context) |
| | | { |
| | | await context.GetRequiredService<IBackgroundWorkerManager>().AddAsync(context.GetRequiredService<WareCmsUtilityApiWorker>()); |
| | | |
| | | await base.AfterReadyAsync(context); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System.Reflection; |
| | | using CMS.Extensions.Abp; |
| | | using CMS.Extensions.Abp.AspNetCore; |
| | | using CMS.Plugin.WareCmsUtilityApi.Abstractions; |
| | | using CMS.Plugin.WareCmsUtilityApi.Application; |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using CMS.Plugin.WareCmsUtilityApi.Jobs; |
| | | using Volo.Abp.BackgroundJobs; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi |
| | | { |
| | | /// <summary> |
| | | /// CMS æä»¶ä¾èµå è½½å¯å¨æ¨¡å |
| | | /// </summary> |
| | | [DependsOn( |
| | | typeof(CMSPluginAbpModule), |
| | | typeof(CMSPluginAbpAspNetCoreModule), |
| | | typeof(CMSPluginApplicationModule), |
| | | typeof(CMSPluginEntityFrameworkCoreModule) |
| | | )] |
| | | public class CMSPluginModule : AbpStartupModule |
| | | { |
| | | /// <inheritdoc /> |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | Configure<AbpBackgroundJobOptions>(options => |
| | | { |
| | | options.AddJob<WareCmsUtilityApiJob>(); |
| | | }); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override Assembly[]? GetSharedAssemblies() |
| | | { |
| | | return base.GetSharedAssemblies().Concat(new[] |
| | | { |
| | | typeof(CMSPluginWareCmsUtilityApiAbstractionsModule).Assembly, |
| | | }).ToArray(); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Data; |
| | | using CMS.Project.Abstractions; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Logging; |
| | | using Volo.Abp.DependencyInjection; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi |
| | | { |
| | | /// <summary> |
| | | /// å·¥ç¨æ°æ®åºè¿ç§»å¨ï¼å½<see cref="IProjectRunner"/>å è½½å·¥ç¨æ¶æ¤å¯¹è±¡ä¼è¢«å建è°ç¨ |
| | | /// </summary> |
| | | public class CMSPluginRuntimeMigrator : IProjectRuntimeMigrator |
| | | { |
| | | /// <summary> |
| | | /// æ§è¡è¿ç§» |
| | | /// </summary> |
| | | /// <param name="project">å½åè¦è¿è¡çå·¥ç¨</param> |
| | | /// <param name="serviceProvider">åå¨è¿è¡å·¥ç¨ä¸ä¸æçserviceProvider</param> |
| | | /// <returns></returns> |
| | | public async Task UpgradeAsync(Project.Project project, IServiceProvider serviceProvider) |
| | | { |
| | | var objectAccessor = serviceProvider.GetService<ObjectAccessor<Project.Project>>(); |
| | | if (objectAccessor != null) |
| | | { |
| | | objectAccessor.Value = project; |
| | | } |
| | | |
| | | var logger = serviceProvider.GetRequiredService<ILogger<CMSPluginRuntimeMigrator>>(); |
| | | try |
| | | { |
| | | // éè¿serviceProviderè·åèªå·±çDbContextå¹¶è¿è¡å建æè¿ç§»æµç¨ |
| | | logger.LogInformation($"Start {project.Info.Id} WareCmsUtilityApi dbcontext create"); |
| | | await serviceProvider.GetRequiredService<CMSPluginDbMigrationService>().MigrateAsync(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | logger.LogError(ex, "Create WareCmsUtilityApi db failed"); |
| | | } |
| | | |
| | | if (objectAccessor != null) |
| | | { |
| | | objectAccessor.Value = null; |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Ao.Lang; |
| | | using CMS.Extensions.Abp.AspNetCore.Mvc.Filters; |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Services; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Http; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using MiniExcelLibs; |
| | | using System.Reflection; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Application.Dtos; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Controller |
| | | { |
| | | /// <summary> |
| | | /// Sampleæå¡ |
| | | /// </summary> |
| | | [ApiController] |
| | | [TypeFilter(typeof(CMSLanguageFilter))] |
| | | [TypeFilter(typeof(CMSUowActionFilter))] |
| | | [TypeFilter(typeof(CMSAuditActionFilter))] |
| | | [TypeFilter(typeof(CMSExceptionFilter))] |
| | | [Route("api/v{version:apiVersion}/WareCmsUtilityApi/[controller]")] |
| | | public class SampleController : ControllerBase |
| | | { |
| | | private readonly ISampleAppService _sampleAppService; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="SampleController"/> class. |
| | | /// </summary> |
| | | /// <param name="sampleAppService">The sample application service.</param> |
| | | public SampleController(ISampleAppService sampleAppService) |
| | | { |
| | | _sampleAppService = sampleAppService; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åsample. |
| | | /// </summary> |
| | | /// <param name="id">æ è¯ç¬¦.</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | [Route("{id}")] |
| | | public virtual Task<SampleDto> GetAsync(Guid id) |
| | | { |
| | | return _sampleAppService.GetAsync(id); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åsampleçå表. |
| | | /// </summary> |
| | | /// <param name="input">è¾å
¥.</param> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | public virtual Task<PagedResultDto<SampleDto>> GetListAsync([FromQuery] GetSamplesInput input) |
| | | { |
| | | return _sampleAppService.GetListAsync(input); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å建sample. |
| | | /// </summary> |
| | | /// <param name="input">è¾å
¥.</param> |
| | | /// <returns></returns> |
| | | //[Authorize] |
| | | [HttpPost] |
| | | public virtual Task<SampleDto> CreateAsync(SampleCreateDto input) |
| | | { |
| | | return _sampleAppService.CreateAsync(input); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ´æ°sample. |
| | | /// </summary> |
| | | /// <param name="id">æ è¯ç¬¦.</param> |
| | | /// <param name="input">è¾å
¥.</param> |
| | | /// <returns></returns> |
| | | //[Authorize] |
| | | [HttpPut] |
| | | [Route("{id}")] |
| | | public virtual Task<SampleDto> UpdateAsync(Guid id, SampleUpdateDto input) |
| | | { |
| | | return _sampleAppService.UpdateAsync(id, input); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å
éSample. |
| | | /// </summary> |
| | | /// <param name="ids">Idéå.</param> |
| | | /// <returns></returns> |
| | | //[Authorize] |
| | | [HttpPost] |
| | | [Route("Clone")] |
| | | public virtual Task<List<SampleDto>> CloneAsync([FromBody] IEnumerable<Guid> ids) |
| | | { |
| | | return _sampleAppService.CloneAsync(ids); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å é¤sample. |
| | | /// </summary> |
| | | /// <param name="id">æ è¯ç¬¦.</param> |
| | | /// <returns></returns> |
| | | //[Authorize] |
| | | [HttpDelete] |
| | | [Route("{id}")] |
| | | public virtual Task DeleteAsync(Guid id) |
| | | { |
| | | return _sampleAppService.DeleteAsync(id); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¹éå é¤sample. |
| | | /// </summary> |
| | | /// <param name="ids">The ids.</param> |
| | | /// <returns></returns> |
| | | //[Authorize] |
| | | [HttpDelete] |
| | | public virtual Task DeleteAsync([FromBody] IEnumerable<Guid> ids) |
| | | { |
| | | return _sampleAppService.DeleteManyAsync(ids); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è°æ´æåº. |
| | | /// </summary> |
| | | /// <param name="id">æ è¯ç¬¦.</param> |
| | | /// <returns></returns> |
| | | [HttpPut] |
| | | [Route("{id}/AdjustSort/{sort}")] |
| | | public virtual Task AdjustSortAsync(Guid id, int sort) |
| | | { |
| | | return _sampleAppService.AdjustSortAsync(id, sort); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 导å
¥sample. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Authorize] |
| | | [HttpPost] |
| | | [Route("Import")] |
| | | public virtual async Task<IActionResult> ImportAsync(IFormFile file) |
| | | { |
| | | using var stream = new MemoryStream(); |
| | | await file.CopyToAsync(stream); |
| | | stream.Seek(0L, SeekOrigin.Begin); |
| | | |
| | | var sheetNames = stream.GetSheetNames(); |
| | | var sampleRows = sheetNames.Contains("é
ç½®") ? MiniExcel.Query<SamplesImportModel.SampleImportModel>(stream, sheetName: "é
ç½®").ToList() : new(); |
| | | |
| | | if (!sampleRows.Any()) |
| | | { |
| | | throw new UserFriendlyException("è¯·æ£æ¥å¯¼å
¥çè¡¨æ ¼"); |
| | | } |
| | | |
| | | await _sampleAppService.ImportAsync(new SamplesImportModel |
| | | { |
| | | Samples = sampleRows, |
| | | }); |
| | | |
| | | return Ok(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 导åºsample. |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [HttpGet] |
| | | [Route("Export")] |
| | | public virtual async Task<IActionResult> ExportAsync([FromQuery] GetSamplesInput input) |
| | | { |
| | | input.MaxResultCount = int.MaxValue; |
| | | var exportData = await _sampleAppService.ExportAsync(input); |
| | | var templatePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Resources/Templates/Sampleå¯¼åºæ¨¡æ¿.xlsx"); |
| | | if (!System.IO.File.Exists(templatePath)) |
| | | { |
| | | templatePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty, $"Resources/Templates/Sampleå¯¼åºæ¨¡æ¿.xlsx"); |
| | | } |
| | | |
| | | var memoryStream = new MemoryStream(); |
| | | await memoryStream.SaveAsByTemplateAsync(templatePath, exportData.Sheets); |
| | | memoryStream.Seek(0L, SeekOrigin.Begin); |
| | | return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") { FileDownloadName = $"{exportData.FileName}_{DateTime.Now:yyyyMMddhhmmss}.xlsx" }; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.MesSuite.Abstractions.Events; |
| | | using CMS.Plugin.MesSuite.Abstractions.Models; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | using CMS.Plugin.OrderManagement.Abstractions.Models; |
| | | using CMS.Plugin.ProcessManagement.Abstractions.Models; |
| | | using CMS.Plugin.TraceManagement.Abstractions.Models.Traces; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Logging; |
| | | using Volo.Abp.DependencyInjection; |
| | | using Volo.Abp.EventBus.Distributed; |
| | | using Volo.Abp.Uow; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EventHandlers |
| | | { |
| | | /// <summary> |
| | | /// æµç¨äºä»¶å¤çç¨åº |
| | | /// </summary> |
| | | public class WareCmsUtilityApiEventHandler : IDistributedEventHandler<ProcessFlowEto>, ITransientDependency |
| | | { |
| | | private readonly ILogger _logger; |
| | | private readonly IServiceProvider _serviceProvider; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="WareCmsUtilityApiEventHandler"/> class. |
| | | /// </summary> |
| | | /// <param name="logger">The logger.</param> |
| | | /// <param name="serviceProvider">The service provider.</param> |
| | | public WareCmsUtilityApiEventHandler(ILogger<WareCmsUtilityApiEventHandler> logger, IServiceProvider serviceProvider) |
| | | { |
| | | this._logger = logger; |
| | | this._serviceProvider = serviceProvider; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Handler handles the event by implementing this method. |
| | | /// </summary> |
| | | /// <param name="eventData">Event data</param> |
| | | public async Task HandleEventAsync(ProcessFlowEto eventData) |
| | | { |
| | | if (eventData.Activity.Equals("æ¥éª¤åç§°")) |
| | | { |
| | | _logger.LogInformation($"SampleEventHandler: Activity={eventData.Activity}"); |
| | | |
| | | var serialNumber = eventData?.FlowItems[FlowItemCollection.SerialNumber]?.ToString(); |
| | | |
| | | // å·¥èºæ¨¡å |
| | | var process = eventData?.FlowItems[FlowItemCollection.ApplicationData] as ProcessModel; |
| | | |
| | | // äº§åæ¨¡å |
| | | var product = eventData?.FlowItems[FlowItemCollection.ProductModel] as AssociationProductModel; |
| | | |
| | | // 追溯模å |
| | | var trace = eventData?.FlowItems[FlowItemCollection.TraceModel] as TraceModel; |
| | | |
| | | // 工忍¡å |
| | | var order = eventData?.FlowItems[FlowItemCollection.OrderModel] as OrderModel; |
| | | |
| | | // ä¸å¡å¤ç |
| | | await ProcessAsync(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Processes the asynchronous. |
| | | /// </summary> |
| | | private async Task ProcessAsync() |
| | | { |
| | | using var scope = _serviceProvider.CreateScope(); |
| | | var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
| | | using var uow = unitOfWorkManager.Begin(requiresNew: true); |
| | | var sampleRepository = scope.ServiceProvider.GetRequiredService<ISampleRepository>(); |
| | | var count = await sampleRepository.GetCountAsync(); |
| | | |
| | | // å¦æææ´æ°æ°æ®åºæä½ï¼éæäº¤ä¿å |
| | | // await uow.SaveChangesAsync(); |
| | | |
| | | _logger.LogInformation($"ProcessAsyncï¼Count={count}"); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.FlowManagement.Abstractions; |
| | | using CMS.Plugin.FlowManagement.Abstractions.Models; |
| | | using CMS.Plugin.MesSuite.Abstractions.Models; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | using CMS.Plugin.OrderManagement.Abstractions.Models; |
| | | using CMS.Plugin.ProcessManagement.Abstractions.Models; |
| | | using CMS.Plugin.TraceManagement.Abstractions.Models.Traces; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Logging; |
| | | using SYC.Flow.Kernel; |
| | | using Volo.Abp.DependencyInjection; |
| | | using Volo.Abp.Uow; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.FlowProcessors |
| | | { |
| | | /// <summary> |
| | | /// æµç¨å¤çå¨ |
| | | /// </summary> |
| | | public class WareCmsUtilityApiFlowProcessor : IFlowProcessor, ISingletonDependency |
| | | { |
| | | private readonly ILogger<WareCmsUtilityApiFlowProcessor> _logger; |
| | | private readonly IServiceProvider _serviceProvider; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="FlowProcessor"/> class. |
| | | /// </summary> |
| | | public WareCmsUtilityApiFlowProcessor(ILogger<WareCmsUtilityApiFlowProcessor> logger, IServiceProvider serviceProvider) |
| | | { |
| | | _logger = logger; |
| | | _serviceProvider = serviceProvider; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public Task OnEnterAsync(FlowProcessor flowProcessor, object sender, EventArgs args) |
| | | { |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task OnExecuteAsync(FlowProcessor flowProcessor, object sender, EventArgs args) |
| | | { |
| | | if (sender is Activity activity) |
| | | { |
| | | var eventArgs = args as ProcessflowEventArgs; |
| | | var procID = eventArgs.DataItems["Instance_ProcID"]; |
| | | if (activity?.Name == "ç¬¬ä¸æ¹ç³»ç»åæ ¼å¤æ") |
| | | { |
| | | // å·¥èºæ¨¡å |
| | | var processModel = eventArgs.DataItems.ApplicationData as ProcessModel; |
| | | |
| | | // 工忍¡å |
| | | var orderModel = eventArgs.DataItems[FlowItemCollection.OrderModel] as OrderModel; |
| | | |
| | | // äº§åæ¨¡å |
| | | var productModel = eventArgs.DataItems[FlowItemCollection.ProductModel] as AssociationProductModel; |
| | | |
| | | // 追溯模å |
| | | var traceModel = eventArgs.DataItems[FlowItemCollection.TraceModel] as TraceModel; |
| | | |
| | | // ä¸å¡å¤ç |
| | | await ProcessAsync(); |
| | | |
| | | _logger.LogInformation($"æ§è¡æµç¨ï¼å®ä¾={procID} -> {flowProcessor.ProcName} -> {activity.Name} ProductionFlowProcessor"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Processes the asynchronous. |
| | | /// </summary> |
| | | private async Task ProcessAsync() |
| | | { |
| | | using var scope = _serviceProvider.CreateScope(); |
| | | var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
| | | using var uow = unitOfWorkManager.Begin(requiresNew: true); |
| | | var sampleRepository = scope.ServiceProvider.GetRequiredService<ISampleRepository>(); |
| | | var count = await sampleRepository.GetCountAsync(); |
| | | |
| | | // å¦æææ´æ°æ°æ®åºæä½ï¼éæäº¤ä¿å |
| | | // await uow.SaveChangesAsync(); |
| | | |
| | | _logger.LogInformation($"ProcessAsyncï¼Count={count}"); |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public Task OnExitAsync(FlowProcessor flowProcessor, object sender, EventArgs args) |
| | | { |
| | | return Task.CompletedTask; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <ProcessflowDefine Version="1"> |
| | | <Define> |
| | | <ProcessflowBuilder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
| | | <Parameters/> |
| | | <Name>WareCmsUtilityApiä¸å¡æµç¨</Name> |
| | | <Description></Description> |
| | | <Root xsi:type="Activity"> |
| | | <Alias>å¯å¨</Alias> |
| | | <Name>å¯å¨</Name> |
| | | <Description></Description> |
| | | <EnterMode>Automatic</EnterMode> |
| | | <ExitMode>Automatic</ExitMode> |
| | | <JoinType>JoinXOR</JoinType> |
| | | <SplitType>SplitXOR</SplitType> |
| | | <ExtendedProperty></ExtendedProperty> |
| | | </Root> |
| | | <Activities> |
| | | <Activity xsi:type="VariableMonitorActivity"> |
| | | <Alias>åéçå¬</Alias> |
| | | <Name>触åä¿¡å·çå¬</Name> |
| | | <EnterMode>Automatic</EnterMode> |
| | | <ExitMode>Automatic</ExitMode> |
| | | <JoinType>JoinXOR</JoinType> |
| | | <SplitType>SplitXOR</SplitType> |
| | | <NeedTagChange>true</NeedTagChange> |
| | | <TaskDelay>0</TaskDelay> |
| | | <MonitorVariableName>WareCmsUtilityApi_TriggerSignal</MonitorVariableName> |
| | | <CompareVariableValue>1</CompareVariableValue> |
| | | <ExtendedProperty></ExtendedProperty> |
| | | </Activity> |
| | | <Activity xsi:type="VariableReadActivity"> |
| | | <Alias>åé读å</Alias> |
| | | <Name>åé读å</Name> |
| | | <EnterMode>Automatic</EnterMode> |
| | | <ExitMode>Automatic</ExitMode> |
| | | <JoinType>JoinXOR</JoinType> |
| | | <SplitType>SplitXOR</SplitType> |
| | | <TaskDelay>0</TaskDelay> |
| | | <ReadRetryCount>10</ReadRetryCount> |
| | | <ReadRetryDelay>500</ReadRetryDelay> |
| | | <ExtendedProperty></ExtendedProperty> |
| | | <ParameterVariables> |
| | | <ReadParameterVariable> |
| | | <VariableName>WareCmsUtilityApi_BarcodeVariable</VariableName> |
| | | <WriteIntoExtAttribute>true</WriteIntoExtAttribute> |
| | | </ReadParameterVariable> |
| | | </ParameterVariables> |
| | | </Activity> |
| | | <Activity xsi:type="WareCmsUtilityApiActivity"> |
| | | <Alias>åéçå¬</Alias> |
| | | <Name>æ©å±æ¥éª¤</Name> |
| | | <EnterMode>Automatic</EnterMode> |
| | | <ExitMode>Automatic</ExitMode> |
| | | <JoinType>JoinXOR</JoinType> |
| | | <SplitType>SplitXOR</SplitType> |
| | | <TaskDelay>0</TaskDelay> |
| | | <MyProperty>MyProperty1</MyProperty> |
| | | <ExtendedProperty></ExtendedProperty> |
| | | </Activity> |
| | | <Activity xsi:type="VariableMonitorActivity"> |
| | | <Alias>åéçå¬</Alias> |
| | | <Name>触åä¿¡å·å¤ä½çå¬</Name> |
| | | <EnterMode>Automatic</EnterMode> |
| | | <ExitMode>Automatic</ExitMode> |
| | | <JoinType>JoinXOR</JoinType> |
| | | <SplitType>SplitXOR</SplitType> |
| | | <NeedTagChange>true</NeedTagChange> |
| | | <TaskDelay>0</TaskDelay> |
| | | <MonitorVariableName>WareCmsUtilityApi_TriggerSignal</MonitorVariableName> |
| | | <CompareVariableValue>0</CompareVariableValue> |
| | | <ExtendedProperty></ExtendedProperty> |
| | | </Activity> |
| | | <Activity xsi:type="BusinessActivity"> |
| | | <Alias>éç¨æ¥éª¤</Alias> |
| | | <Name>éç¨æ¥éª¤</Name> |
| | | <EnterMode>Automatic</EnterMode> |
| | | <ExitMode>Automatic</ExitMode> |
| | | <JoinType>JoinXOR</JoinType> |
| | | <SplitType>SplitXOR</SplitType> |
| | | <PublishFlowEvent>true</PublishFlowEvent> |
| | | <TaskDelay>0</TaskDelay> |
| | | <ExtendedProperty> |
| | | <MyExtendedProperty>MyExtendedProperty1</MyExtendedProperty> |
| | | </ExtendedProperty> |
| | | </Activity> |
| | | <Activity xsi:type="VariableWriteActivity"> |
| | | <Alias>åéä¸å</Alias> |
| | | <Name>åéä¸å</Name> |
| | | <EnterMode>Automatic</EnterMode> |
| | | <ExitMode>Automatic</ExitMode> |
| | | <JoinType>JoinXOR</JoinType> |
| | | <SplitType>SplitXOR</SplitType> |
| | | <TaskDelay>0</TaskDelay> |
| | | <WriteRetryCount>10</WriteRetryCount> |
| | | <WriteRetryDelay>500</WriteRetryDelay> |
| | | <ParameterVariables> |
| | | <WriteParameterVariable> |
| | | <Sort>1</Sort> |
| | | <WriteVariableName>WareCmsUtilityApi_BarcodeVariable</WriteVariableName> |
| | | <WriteVariableValue></WriteVariableValue> |
| | | </WriteParameterVariable> |
| | | </ParameterVariables> |
| | | <ExtendedProperty></ExtendedProperty> |
| | | </Activity> |
| | | <Activity xsi:type="EndActivity"> |
| | | <Alias>ç»æ</Alias> |
| | | <Name>ç»æ</Name> |
| | | <EnterMode>Automatic</EnterMode> |
| | | <ExitMode>Automatic</ExitMode> |
| | | <JoinType>JoinXOR</JoinType> |
| | | <SplitType>SplitXOR</SplitType> |
| | | <ExtendedProperty></ExtendedProperty> |
| | | </Activity> |
| | | </Activities> |
| | | <Transitions> |
| | | <Transition> |
| | | <Label>å¯å¨->触åä¿¡å·çå¬</Label> |
| | | <Source>å¯å¨</Source> |
| | | <Sink>触åä¿¡å·çå¬</Sink> |
| | | </Transition> |
| | | <Transition> |
| | | <Label>触åä¿¡å·çå¬->åé读å</Label> |
| | | <Source>触åä¿¡å·çå¬</Source> |
| | | <Sink>åé读å</Sink> |
| | | </Transition> |
| | | <Transition> |
| | | <Label>åé读å->æ©å±æ¥éª¤</Label> |
| | | <Source>åé读å</Source> |
| | | <Sink>æ©å±æ¥éª¤</Sink> |
| | | </Transition> |
| | | <Transition> |
| | | <Label>æ©å±æ¥éª¤->触åä¿¡å·å¤ä½çå¬</Label> |
| | | <Source>æ©å±æ¥éª¤</Source> |
| | | <Sink>触åä¿¡å·å¤ä½çå¬</Sink> |
| | | </Transition> |
| | | <Transition> |
| | | <Label>触åä¿¡å·å¤ä½çå¬->éç¨æ¥éª¤</Label> |
| | | <Source>触åä¿¡å·å¤ä½çå¬</Source> |
| | | <Sink>éç¨æ¥éª¤</Sink> |
| | | </Transition> |
| | | <Transition> |
| | | <Label>éç¨æ¥éª¤->åéä¸å</Label> |
| | | <Source>éç¨æ¥éª¤</Source> |
| | | <Sink>åéä¸å</Sink> |
| | | </Transition> |
| | | <Transition> |
| | | <Label>åéä¸å->ç»æ</Label> |
| | | <Source>åéä¸å</Source> |
| | | <Sink>ç»æ</Sink> |
| | | </Transition> |
| | | </Transitions> |
| | | </ProcessflowBuilder> |
| | | </Define> |
| | | <Appearance> |
| | | <ProcessflowAppearance xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> |
| | | </ProcessflowAppearance> |
| | | </Appearance> |
| | | </ProcessflowDefine> |
copy from "Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/UtilityApi/src/CMS.Plugin.HIAWms.Abstractions/FodyWeavers.xml"
copy to "Weben_CMS\344\270\223\347\224\250\344\273\243\347\240\201\347\224\237\346\210\220\345\231\250/WareCmsUtilityApi/server/src/CMS.Plugin.WareCmsUtilityApi/FodyWeavers.xml"
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Jobs |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApi ä½ä¸åæ° |
| | | /// </summary> |
| | | public class WareCmsUtilityApiArgs |
| | | { |
| | | /// <summary> |
| | | /// Gets or sets the subject. |
| | | /// </summary> |
| | | public string Subject { get; set; } |
| | | |
| | | /// <summary> |
| | | /// Gets or sets the body. |
| | | /// </summary> |
| | | public string Body { get; set; } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | using Microsoft.Extensions.Logging; |
| | | using Volo.Abp.BackgroundJobs; |
| | | using Volo.Abp.DependencyInjection; |
| | | using Volo.Abp.Uow; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Jobs |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApi åå°ä½ä¸ |
| | | /// </summary> |
| | | public class WareCmsUtilityApiJob : BackgroundJob<WareCmsUtilityApiArgs>, ITransientDependency |
| | | { |
| | | private readonly ILogger<WareCmsUtilityApiJob> _logger; |
| | | private readonly IUnitOfWorkManager _unitOfWorkManager; |
| | | private readonly ISampleRepository _sampleRepository; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="WareCmsUtilityApiJob"/> class. |
| | | /// </summary> |
| | | /// <param name="logger">The logger.</param> |
| | | /// <param name="unitOfWorkManager">The unit of work manager.</param> |
| | | /// <param name="sampleRepository">My entity name repository.</param> |
| | | public WareCmsUtilityApiJob(ILogger<WareCmsUtilityApiJob> logger, IUnitOfWorkManager unitOfWorkManager, ISampleRepository sampleRepository) |
| | | { |
| | | _logger = logger; |
| | | _unitOfWorkManager = unitOfWorkManager; |
| | | _sampleRepository = sampleRepository; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public override void Execute(WareCmsUtilityApiArgs args) |
| | | { |
| | | using var uow = _unitOfWorkManager.Begin(requiresNew: true); |
| | | var count = _sampleRepository.GetCountAsync().GetAwaiter().GetResult(); |
| | | |
| | | // å¦æææ´æ°æ°æ®åºæä½ï¼éæäº¤ä¿å |
| | | // uow.SaveChangesAsync().GetAwaiter().GetResult(); |
| | | |
| | | _logger.LogInformation($"WareCmsUtilityApiJob Executeï¼Subject={args.Subject}ï¼Body={args.Body}ï¼Count={count}"); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.FlowManagement.Abstractions.FlowBusiness; |
| | | using CMS.Plugin.WareCmsUtilityApi.Apis; |
| | | using CMS.Plugin.WareCmsUtilityApi.Application.Contracts.Dtos.Samples; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | using CMS.Plugin.WareCmsUtilityApi.Jobs; |
| | | using CMS.Project; |
| | | using CMS.Project.Abstractions; |
| | | using CMS.Unit.RuntimeValue.Abstractions; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Logging; |
| | | using Volo.Abp.BackgroundJobs; |
| | | using Volo.Abp.Uow; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.ProjectService |
| | | { |
| | | /// <summary> |
| | | /// å·¥ç¨æå¡ï¼åå·¥ç¨å
³èçåå°æå¡ï¼å½<see cref="IProjectServiceRunner"/>以å½åKeyè°ç¨æ¶ä¼è¢«æ§è¡ |
| | | /// </summary> |
| | | public class WareCmsUtilityApiProjectService : BaseProjectService |
| | | { |
| | | private IServiceProvider _serviceProvider; |
| | | private readonly ILogger<WareCmsUtilityApiProjectService> _logger; |
| | | private readonly IVariableDataCache _variableDataCache; |
| | | private FlowVariableChannelListener _channelListener; |
| | | private Dictionary<string, string> _monitorVariableNames; |
| | | |
| | | /// <summary> |
| | | /// æå¡çKeyï¼å¯ä¸ï¼ä¾<see cref="IProjectServiceRunner"/>ä½¿ç¨ |
| | | /// </summary> |
| | | public override string Key => "WareCmsUtilityApi"; |
| | | |
| | | /// <summary> |
| | | /// æå¡æè¿°ï¼æ¾ç¤ºå¨æå¡å表UIä¸çåç§° |
| | | /// </summary> |
| | | public override string Description => "WareCmsUtilityApiæå¡"; |
| | | |
| | | /// <summary> |
| | | /// å¯ç¨ææ |
| | | /// </summary> |
| | | public override bool AuthRequired => true; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="WareCmsUtilityApiProjectService"/> class. |
| | | /// </summary> |
| | | /// <param name="logger">The logger.</param> |
| | | /// <param name="variableDataCache">The variable data cache.</param> |
| | | public WareCmsUtilityApiProjectService(IServiceProvider serviceProvider, ILogger<WareCmsUtilityApiProjectService> logger, IVariableDataCache variableDataCache) |
| | | { |
| | | _serviceProvider = serviceProvider; |
| | | _logger = logger; |
| | | _variableDataCache = variableDataCache; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¼å¯æå¡ |
| | | /// </summary> |
| | | /// <param name="serviceProvider">å
·æå·¥ç¨ä¸ä¸æçå®ä¾</param> |
| | | public override async Task StartAsync(IServiceProvider serviceProvider) |
| | | { |
| | | if (State == ProjectServiceState.Started) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | // çå¬åé |
| | | _monitorVariableNames = new Dictionary<string, string> |
| | | { |
| | | { "WareCmsUtilityApi_Variable1", "çå¬åé1" }, |
| | | { "WareCmsUtilityApi_Variable2", "çå¬åé2" } |
| | | }; |
| | | |
| | | // å建ééçå¬ |
| | | _channelListener?.Token?.Dispose(); |
| | | _channelListener = new FlowVariableChannelListener(_logger, _variableDataCache); |
| | | _channelListener.CreateChannel(Key, waitListener: false, timeout: TimeSpan.FromSeconds(30), variableFilter: _monitorVariableNames.Keys.ToHashSet()); |
| | | _channelListener.TagChanged += OnTagValueChanged; |
| | | |
| | | await base.StartAsync(serviceProvider); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 忢æå¡ |
| | | /// </summary> |
| | | /// <param name="serviceProvider">å
·æå·¥ç¨ä¸ä¸æçå®ä¾</param> |
| | | public override async Task StopAsync(IServiceProvider serviceProvider) |
| | | { |
| | | if (_channelListener != null) |
| | | { |
| | | // éæ¾çå¬ |
| | | _channelListener.TagChanged -= OnTagValueChanged; |
| | | _channelListener.Token.Dispose(); |
| | | _channelListener = null; |
| | | } |
| | | |
| | | // 使ç¨åå°ä½ä¸å¼æ¥å¤ç |
| | | //await _serviceProvider.GetRequiredService<IBackgroundJobManager>().EnqueueAsync(new WareCmsUtilityApiArgs |
| | | //{ |
| | | // Subject = "WareCmsUtilityApi_Subject", |
| | | // Body = "WareCmsUtilityApi_Body", |
| | | //}); |
| | | |
| | | |
| | | await base.StopAsync(serviceProvider); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Called when [tag value changed]. |
| | | /// </summary> |
| | | /// <param name="sender">The sender.</param> |
| | | /// <param name="e">The <see cref="TagChangedEventArgs"/> instance containing the event data.</param> |
| | | private async void OnTagValueChanged(object sender, TagChangedEventArgs e) |
| | | { |
| | | var changeds = e.Changeds.Where(x => _monitorVariableNames != null && _monitorVariableNames.ContainsKey(x.Name)); |
| | | if (!changeds.Any()) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | foreach (var changed in changeds) |
| | | { |
| | | var oldValue = changed.Old?.Value; |
| | | var newValue = changed.New?.Value; |
| | | var traceId = e.TraceId; |
| | | |
| | | _logger.LogInformation($"{changed.Name} åéå¼åçååï¼æ§å¼{oldValue}=æ°å¼{newValue}ï¼TraceId={traceId}"); |
| | | |
| | | // TODO: å¤çåéå¼åå |
| | | // Tipsï¼https://cms-docs.shengyc.com/cms/api/%E5%90%8E%E7%AB%AF#3-%E5%8F%98%E9%87%8F%E6%A8%A1%E5%9D%97 |
| | | /* 说æï¼éè¿è®¢é
IVariableDataCache.TagChanged äºä»¶ï¼æ¨å¯ä»¥å®æ¶çæ§åéçååãæ¤äºä»¶ä¼ä¼ éææåéè³äºä»¶å¤ç彿°ï¼å æ¤ï¼ä¸å¡å±éå¨å½æ°ä¸çéå
³æ³¨çåéã |
| | | 注æäºé¡¹ï¼ |
| | | ï¼1ï¼æ§è½å½±åï¼ åå¸äºä»¶æ¶ï¼äºä»¶çåéè
å°é»å¡æµç¨ãå æ¤ï¼å¼ºç建议é¿å
å¨äºä»¶å¤ç彿°ä¸æ§è¡ I/ O æä½ãHTTP æ¥å£è®¿é®æå
¶ä»èæ¶æä½ï¼ä»¥é²æ¢å¯¹ç³»ç»æ§è½äº§ç严éå½±åï¼å¯¼è´æ´ä¸ªç³»ç»ååºå»¶è¿ã |
| | | ï¼2ï¼é«é¢ç触åï¼ ç±äºäºä»¶è®¢é
äºå
¨éåéï¼è§¦åé¢çå¯è½é常é«ã |
| | | ï¼3ï¼å¼æ¥å¤çï¼ é´äºäºä»¶è§¦åé¢çå¾é«ï¼å»ºè®®ä¸å¡å±å¨çéå
³æ³¨åéåï¼ä½¿ç¨ Task å¯å¨æ°çº¿ç¨å¤çä¸å¡é»è¾ï¼ä»¥é¿å
é»å¡æ ¸å¿çåéçå¬åè½ï¼å®ç°ä¸å¡å±ä¸å¹³å°åºåº§çè§£è¦ã |
| | | ï¼4ï¼å¹¶å管çï¼ å¦æä¸å¡å±å¹¶åé大ï¼å¿
é¡»ä¼å代ç 设计å宿½ï¼ä»¥åå°å¨é«å¹¶åæ
åµä¸çç³»ç»èµæºæ¶èï¼é²æ¢ç³»ç»æ§è½é®é¢ã |
| | | ï¼5ï¼ä»£ç å®å
¨ï¼ å®è£
å¹¶ä½¿ç¨ CMS.CodeAnalysis åæå¨æ¥åæ IVariableDataCache.TagChanged çä½¿ç¨æ
åµã该工å
·è½å¨ä½¿ç¨ä¸å½æ¶æä¾ç¼è¯é误ï¼å¸®å©æ¨æé«ä»£ç è´¨éã*/ |
| | | |
| | | _ = Task.Run(async () => |
| | | { |
| | | // ä¾1ï¼åæ¥å¤ç |
| | | //await ProcessAsync(); |
| | | |
| | | // ä¾2ï¼è°ç¨å¤é¨API |
| | | //await ExecuteExternalApiAsync(); |
| | | }); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Processes the asynchronous. |
| | | /// </summary> |
| | | private async Task ProcessAsync() |
| | | { |
| | | using var scope = _serviceProvider.CreateScope(); |
| | | var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
| | | using var uow = unitOfWorkManager.Begin(requiresNew: true); |
| | | var sampleRepository = scope.ServiceProvider.GetRequiredService<ISampleRepository>(); |
| | | var count = await sampleRepository.GetCountAsync(); |
| | | |
| | | // å¦æææ´æ°æ°æ®åºæä½ï¼éæäº¤ä¿å |
| | | // await uow.SaveChangesAsync(); |
| | | |
| | | _logger.LogInformation($"ProcessAsyncï¼Count={count}"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Executes the external API. |
| | | /// </summary> |
| | | private async Task ExecuteExternalApiAsync() |
| | | { |
| | | try |
| | | { |
| | | await _serviceProvider.GetRequiredService<IWareCmsUtilityApiExternalApi>().CreateAsync(new SampleCreateDto |
| | | { |
| | | Name = "Sample_Name", |
| | | Code = "Sample_Code", |
| | | }); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | _logger.LogException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Abstractions; |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Samples; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Logging; |
| | | using SYC.Flow.Kernel; |
| | | using Volo.Abp.DependencyInjection; |
| | | using Volo.Abp.Uow; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Services |
| | | { |
| | | /// <inheritdoc /> |
| | | public class WareCmsUtilityApiFlowService : IWareCmsUtilityApiFlowService, ITransientDependency |
| | | { |
| | | private readonly ILogger<WareCmsUtilityApiFlowService> _logger; |
| | | private readonly IServiceProvider _serviceProvider; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="WareCmsUtilityApiFlowService"/> class. |
| | | /// </summary> |
| | | /// <param name="logger">The logger.</param> |
| | | public WareCmsUtilityApiFlowService(ILogger<WareCmsUtilityApiFlowService> logger, IServiceProvider serviceProvider) |
| | | { |
| | | _logger = logger; |
| | | _serviceProvider = serviceProvider; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | public async Task ProcessAsync(ProcessflowEventArgs args) |
| | | { |
| | | using var scope = _serviceProvider.CreateScope(); |
| | | var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
| | | using var uow = unitOfWorkManager.Begin(requiresNew: true); |
| | | var sampleRepository = scope.ServiceProvider.GetRequiredService<ISampleRepository>(); |
| | | var count = await sampleRepository.GetCountAsync(); |
| | | |
| | | // å¦æææ´æ°æ°æ®åºæä½ï¼éæäº¤ä¿å |
| | | // await uow.SaveChangesAsync(); |
| | | |
| | | // è¾åºæ¥å¿ |
| | | _logger.LogInformation($"WareCmsUtilityApiFlowServiceï¼ProcessAsync()"); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Extensions.Variable; |
| | | using CMS.Project.Abstractions; |
| | | using KissUtil.Extensions; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Microsoft.Extensions.Logging; |
| | | using Volo.Abp.BackgroundWorkers; |
| | | using Volo.Abp.Threading; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Workers |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApiåå°å·¥ä½è
|
| | | /// </summary> |
| | | public class WareCmsUtilityApiWorker : AsyncPeriodicBackgroundWorkerBase |
| | | { |
| | | private readonly ILogger<WareCmsUtilityApiWorker> _logger; |
| | | private readonly VariableService _variableService; |
| | | |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="WareCmsUtilityApiWorker"/> class. |
| | | /// </summary> |
| | | /// <param name="timer">The timer.</param> |
| | | /// <param name="serviceScopeFactory">The service scope factory.</param> |
| | | public WareCmsUtilityApiWorker(ILogger<WareCmsUtilityApiWorker> logger, AbpAsyncTimer timer, VariableService variableService, IServiceScopeFactory serviceScopeFactory) : base(timer, serviceScopeFactory) |
| | | { |
| | | _logger = logger; |
| | | _variableService = variableService; |
| | | Timer.Period = 1 * 300 * 1000; // æ¯é 300 ç§ æ§è¡ä¸æ¬¡ |
| | | Timer.RunOnStart = true; |
| | | } |
| | | |
| | | /// <inheritdoc /> |
| | | protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) |
| | | { |
| | | var projectAccessor = workerContext.ServiceProvider.GetRequiredService<IProjectAccessor>(); |
| | | var project = await projectAccessor.GetProjectAsync(); |
| | | if (project?.Info == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | //_logger.LogInformation($"WareCmsUtilityApiWorker is working for project {project.Info.Id}"); |
| | | |
| | | //// 计ç®OEE |
| | | //double oee = await CalculateOEEAsync(); |
| | | |
| | | //// 使ç¨ç¾åæ¯æ ¼å¼ æå°ç»ææ¥å¿ |
| | | //_logger.LogInformation($"OEE:{oee:P2}"); |
| | | |
| | | //// åå
¥åé |
| | | //await _variableService.WriteValueAsync(new Dictionary<string, object> {{ "OEE", oee } }); |
| | | } |
| | | |
| | | // 计ç®OEE=å¯ç¨æ§Ãæ§è½Ãè´¨é |
| | | public async Task<double> CalculateOEEAsync() |
| | | { |
| | | // 读åOEEè®¡ç®æéçå¼ |
| | | double availability = await ReadDoubleValueAsync("Availability"); |
| | | double performance = await ReadDoubleValueAsync("Performance"); |
| | | double quality = await ReadDoubleValueAsync("Quality"); |
| | | |
| | | // 计ç®OEE |
| | | double oee = availability * performance * quality; |
| | | |
| | | // è¿å计ç®ç»æ |
| | | return oee; |
| | | } |
| | | |
| | | // æä¾ä¸ä¸ªæ³åæ¹æ³ï¼æ¹ä¾¿ç´æ¥è·ådoubleç±»åçå¼ |
| | | public async Task<double> ReadDoubleValueAsync(string variableName) |
| | | { |
| | | var variable = await _variableService.ReadValueAsync(variableName); |
| | | return (variable?.Content?.Value).SafeString().ToDoubleOrNull().GetValueOrDefault(); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | { |
| | | // é
ç½®æä»¶å°½å¯è½åå¨/host/appsettings.jsonææ°æ®åºä¸ï¼é¿å
æä»¶å级æ¶è¢«è¦ç |
| | | "IWareCmsUtilityApiExternalApi": { |
| | | "HttpHost": "http://127.0.0.1:18000/" // External API对æ¥å°å |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | <Import Project="../../common.test.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\..\src\CMS.Plugin.WareCmsUtilityApi.Application\CMS.Plugin.WareCmsUtilityApi.Application.csproj" /> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.Domain.Tests\CMS.Plugin.WareCmsUtilityApi.Domain.Tests.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using CMS.Plugin.WareCmsUtilityApi.MySQL; |
| | | using CMS.Plugin.WareCmsUtilityApi.TestBase; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Tests |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApiApplicationTestBase |
| | | /// </summary> |
| | | public class WareCmsUtilityApiApplicationTestBase : WareCmsUtilityApiTestBase<WareCmsUtilityApiApplicationTestModule> |
| | | { |
| | | /// <summary> |
| | | /// UsingDbContext |
| | | /// </summary> |
| | | /// <param name="action">IWareCmsUtilityApiDbContext</param> |
| | | protected virtual void UsingDbContext(Action<CMSPluginDbContext> action) |
| | | { |
| | | using (var dbContext = GetRequiredService<CMSPluginDbContext>()) |
| | | { |
| | | action.Invoke(dbContext); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// UsingDbContext |
| | | /// </summary> |
| | | /// <typeparam name="T">T</typeparam> |
| | | /// <param name="action">IWareCmsUtilityApiDbContext</param> |
| | | /// <returns>T</returns> |
| | | protected virtual T UsingDbContext<T>(Func<CMSPluginDbContext, T> action) |
| | | { |
| | | using (var dbContext = GetRequiredService<CMSPluginDbContext>()) |
| | | { |
| | | return action.Invoke(dbContext); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain.Tests; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Application.Tests |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApiApplicationTestModule |
| | | /// </summary> |
| | | [DependsOn( |
| | | typeof(CMSPluginApplicationModule), |
| | | typeof(WareCmsUtilityApiDomainTestModule))] |
| | | public class WareCmsUtilityApiApplicationTestModule : AbpModule |
| | | { |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | base.ConfigureServices(context); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | <Import Project="../../common.test.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Tests\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Tests.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore; |
| | | using CMS.Plugin.WareCmsUtilityApi.MySQL; |
| | | using CMS.Plugin.WareCmsUtilityApi.TestBase; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Tests |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApi DomainTestBase |
| | | /// </summary> |
| | | public class WareCmsUtilityApiDomainTestBase : WareCmsUtilityApiTestBase<WareCmsUtilityApiDomainTestModule> |
| | | { |
| | | /// <summary> |
| | | /// UsingDbContext |
| | | /// </summary> |
| | | /// <param name="action">IWareCmsUtilityApiDbContext</param> |
| | | protected virtual void UsingDbContext(Action<CMSPluginDbContext> action) |
| | | { |
| | | using (var dbContext = GetRequiredService<CMSPluginDbContext>()) |
| | | { |
| | | action.Invoke(dbContext); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// UsingDbContext |
| | | /// </summary> |
| | | /// <typeparam name="T">T</typeparam> |
| | | /// <param name="action">IWareCmsUtilityApiDbContext</param> |
| | | /// <returns>T</returns> |
| | | protected virtual T UsingDbContext<T>(Func<CMSPluginDbContext, T> action) |
| | | { |
| | | using (var dbContext = GetRequiredService<CMSPluginDbContext>()) |
| | | { |
| | | return action.Invoke(dbContext); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Tests; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.Domain.Tests |
| | | { |
| | | /// <summary> |
| | | /// WareCmsUtilityApi DomainTestModule |
| | | /// </summary> |
| | | [DependsOn(typeof(WareCmsUtilityApiTestEntityFrameworkCoreModule))] |
| | | public class WareCmsUtilityApiDomainTestModule : AbpModule |
| | | { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | <Import Project="../../common.test.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.EntityFrameworkCore.Sqlite" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" /> |
| | | <PackageReference Include="NSubstitute" Version="$(NSubstitutePackageVersion)" /> |
| | | <PackageReference Include="Shouldly" Version="$(ShouldlyPackageVersion)" /> |
| | | <PackageReference Include="xunit" Version="$(xUnitPackageVersion)" /> |
| | | <PackageReference Include="xunit.extensibility.execution" Version="$(xUnitExtensibilityExecutionPackageVersion)" /> |
| | | <PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitRunnerVisualstudioPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\..\src\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore\CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.csproj" /> |
| | | <ProjectReference Include="..\..\src\CMS.Plugin.WareCmsUtilityApi.MySQL\CMS.Plugin.WareCmsUtilityApi.MySQL.csproj" /> |
| | | <ProjectReference Include="..\CMS.Plugin.WareCmsUtilityApi.TestBase\CMS.Plugin.WareCmsUtilityApi.TestBase.csproj" /> |
| | | </ItemGroup> |
| | | |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.TestBase; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Tests |
| | | { |
| | | /// <summary> |
| | | /// MyProjectName TestBase |
| | | /// </summary> |
| | | public class WareCmsUtilityApiEntityFrameworkTestBase : WareCmsUtilityApiTestBase<WareCmsUtilityApiTestEntityFrameworkCoreModule> |
| | | { |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.MySQL; |
| | | using CMS.Plugin.WareCmsUtilityApi.TestBase; |
| | | using Microsoft.Data.Sqlite; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore.Infrastructure; |
| | | using Microsoft.EntityFrameworkCore.Storage; |
| | | using Volo.Abp.EntityFrameworkCore; |
| | | using Volo.Abp.EntityFrameworkCore.Sqlite; |
| | | using Volo.Abp.Modularity; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.EntityFrameworkCore.Tests |
| | | { |
| | | /// <summary> |
| | | /// MyProjectName TestEntityFrameworkCoreModule |
| | | /// </summary> |
| | | [DependsOn( |
| | | typeof(WareCmsUtilityApiTestBaseModule), |
| | | typeof(CMSPluginEntityFrameworkCoreModule), |
| | | typeof(AbpEntityFrameworkCoreSqliteModule))] |
| | | public class WareCmsUtilityApiTestEntityFrameworkCoreModule : AbpModule |
| | | { |
| | | /// <summary> |
| | | /// ConfigureServices |
| | | /// </summary> |
| | | /// <param name="context">ServiceConfigurationContext</param> |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | var sqliteConnection = CreateDatabaseAndGetConnection(); |
| | | |
| | | Configure<AbpDbContextOptions>(options => |
| | | { |
| | | options.Configure(dbContextConfigurationContext => |
| | | { |
| | | dbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | private static SqliteConnection CreateDatabaseAndGetConnection() |
| | | { |
| | | var connection = new SqliteConnection("Data Source=:memory:"); |
| | | connection.Open(); |
| | | |
| | | new CMSPluginDbContext( |
| | | new DbContextOptionsBuilder<CMSPluginDbContext>().UseSqlite(connection).Options).GetService<IRelationalDatabaseCreator>().CreateTables(); |
| | | |
| | | return connection; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <Project Sdk="Microsoft.NET.Sdk"> |
| | | <Import Project="../../common.test.props" /> |
| | | |
| | | <PropertyGroup> |
| | | <TargetFramework>net6.0</TargetFramework> |
| | | </PropertyGroup> |
| | | |
| | | <ItemGroup> |
| | | <PackageReference Include="Volo.Abp.Autofac" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.TestBase" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Volo.Abp.Authorization" Version="$(ABPPackageVersion)" /> |
| | | <PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" /> |
| | | <PackageReference Include="NSubstitute" Version="$(NSubstitutePackageVersion)" /> |
| | | <PackageReference Include="Shouldly" Version="$(ShouldlyPackageVersion)" /> |
| | | <PackageReference Include="xunit" Version="$(xUnitPackageVersion)" /> |
| | | <PackageReference Include="xunit.extensibility.execution" Version="$(xUnitExtensibilityExecutionPackageVersion)" /> |
| | | <PackageReference Include="xunit.runner.visualstudio" Version="$(xUnitRunnerVisualstudioPackageVersion)" /> |
| | | </ItemGroup> |
| | | |
| | | <ItemGroup> |
| | | <ProjectReference Include="..\..\src\CMS.Plugin.WareCmsUtilityApi.Domain\CMS.Plugin.WareCmsUtilityApi.Domain.csproj" /> |
| | | </ItemGroup> |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.DependencyInjection; |
| | | using Volo.Abp.Guids; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.TestBase |
| | | { |
| | | /// <summary> |
| | | /// MyProjectName DataSeedContributor |
| | | /// </summary> |
| | | public class WareCmsUtilityApiDataSeedContributor : IDataSeedContributor, ITransientDependency |
| | | { |
| | | private readonly WareCmsUtilityApiTestData _myProjectNameTestData; |
| | | private readonly IGuidGenerator _guidGenerator; |
| | | /// <summary> |
| | | /// Initializes a new instance of the <see cref="WareCmsUtilityApiDataSeedContributor"/> class. |
| | | /// </summary> |
| | | /// <param name="serviceProvider">IServiceProvider</param> |
| | | public WareCmsUtilityApiDataSeedContributor(IServiceProvider serviceProvider) |
| | | { |
| | | _myProjectNameTestData = serviceProvider.GetRequiredService<WareCmsUtilityApiTestData>(); |
| | | _guidGenerator = serviceProvider.GetRequiredService<IGuidGenerator>(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// SeedAsync |
| | | /// </summary> |
| | | /// <param name="context">DataSeedContext</param> |
| | | /// <returns>Task</returns> |
| | | public async Task SeedAsync(DataSeedContext context) |
| | | { |
| | | await Task.CompletedTask; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Modularity; |
| | | using Volo.Abp.Testing; |
| | | using Volo.Abp.Uow; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.TestBase |
| | | { |
| | | /// <summary> |
| | | /// MyProjectName TestBase |
| | | /// </summary> |
| | | /// <typeparam name="TStartupModule">IAbpModule</typeparam> |
| | | public class WareCmsUtilityApiTestBase<TStartupModule> : AbpIntegratedTest<TStartupModule> |
| | | where TStartupModule : IAbpModule |
| | | { |
| | | /// <summary> |
| | | /// SetAbpApplicationCreationOptions |
| | | /// </summary> |
| | | /// <param name="options">AbpApplicationCreationOptions</param> |
| | | protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
| | | { |
| | | options.UseAutofac(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// WithUnitOfWorkAsync |
| | | /// </summary> |
| | | /// <param name="func">func</param> |
| | | /// <returns>Task</returns> |
| | | protected virtual Task WithUnitOfWorkAsync(Func<Task> func) |
| | | { |
| | | return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// WithUnitOfWorkAsync |
| | | /// </summary> |
| | | /// <param name="options">AbpUnitOfWorkOptions</param> |
| | | /// <param name="action">action</param> |
| | | /// <returns>Task</returns> |
| | | protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func<Task> action) |
| | | { |
| | | using (var scope = ServiceProvider.CreateScope()) |
| | | { |
| | | var uowManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
| | | |
| | | using (var uow = uowManager.Begin(options)) |
| | | { |
| | | await action(); |
| | | |
| | | await uow.CompleteAsync(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// WithUnitOfWorkAsync |
| | | /// </summary> |
| | | /// <typeparam name="TResult">t</typeparam> |
| | | /// <param name="func">TResult</param> |
| | | /// <returns>TResult</returns> |
| | | protected virtual Task<TResult> WithUnitOfWorkAsync<TResult>(Func<Task<TResult>> func) |
| | | { |
| | | return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// WithUnitOfWorkAsync |
| | | /// </summary> |
| | | /// <typeparam name="TResult">T</typeparam> |
| | | /// <param name="options">AbpUnitOfWorkOptions</param> |
| | | /// <param name="func">Func</param> |
| | | /// <returns>TResult</returns> |
| | | protected virtual async Task<TResult> WithUnitOfWorkAsync<TResult>(AbpUnitOfWorkOptions options, Func<Task<TResult>> func) |
| | | { |
| | | using (var scope = ServiceProvider.CreateScope()) |
| | | { |
| | | var uowManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
| | | |
| | | using (var uow = uowManager.Begin(options)) |
| | | { |
| | | var result = await func(); |
| | | await uow.CompleteAsync(); |
| | | return result; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using CMS.Plugin.WareCmsUtilityApi.Domain; |
| | | using Microsoft.Extensions.DependencyInjection; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Autofac; |
| | | using Volo.Abp.Data; |
| | | using Volo.Abp.Modularity; |
| | | using Volo.Abp.Threading; |
| | | using Volo.Abp.Uow; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.TestBase |
| | | { |
| | | /// <summary> |
| | | /// MyProjectName TestBaseModule |
| | | /// </summary> |
| | | [DependsOn( |
| | | typeof(AbpAutofacModule), |
| | | typeof(AbpTestBaseModule), |
| | | typeof(CMSPluginDomainModule))] |
| | | public class WareCmsUtilityApiTestBaseModule : AbpModule |
| | | { |
| | | /// <summary> |
| | | /// PreConfigureServices |
| | | /// </summary> |
| | | /// <param name="context">ServiceConfigurationContext</param> |
| | | public override void PreConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ConfigureServices |
| | | /// </summary> |
| | | /// <param name="context">ServiceConfigurationContext</param> |
| | | public override void ConfigureServices(ServiceConfigurationContext context) |
| | | { |
| | | context.Services.AddAlwaysAllowAuthorization(); |
| | | Configure<AbpUnitOfWorkDefaultOptions>(options => |
| | | { |
| | | options.TransactionBehavior = UnitOfWorkTransactionBehavior.Enabled; |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// OnApplicationInitialization |
| | | /// </summary> |
| | | /// <param name="context">ApplicationInitializationContext</param> |
| | | public override void OnApplicationInitialization(ApplicationInitializationContext context) |
| | | { |
| | | SeedTestData(context); |
| | | } |
| | | |
| | | private static void SeedTestData(ApplicationInitializationContext context) |
| | | { |
| | | AsyncHelper.RunSync(async () => |
| | | { |
| | | using (var scope = context.ServiceProvider.CreateScope()) |
| | | { |
| | | var dataSeeder = scope.ServiceProvider.GetRequiredService<IDataSeeder>(); |
| | | await dataSeeder.SeedAsync(); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Volo.Abp.DependencyInjection; |
| | | |
| | | namespace CMS.Plugin.WareCmsUtilityApi.TestBase |
| | | { |
| | | public class WareCmsUtilityApiTestData : ISingletonDependency |
| | | { |
| | | } |
| | | } |