diff --git a/aspnet-core/LINGYUN.MicroService.Workflow.sln b/aspnet-core/LINGYUN.MicroService.Workflow.sln index e7c5d9c34..9f253ed20 100644 --- a/aspnet-core/LINGYUN.MicroService.Workflow.sln +++ b/aspnet-core/LINGYUN.MicroService.Workflow.sln @@ -51,11 +51,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflow-core", "workflow-c EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "elsa", "elsa", "{F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Elsa", "modules\elsa\LINGYUN.Abp.Elsa\LINGYUN.Abp.Elsa.csproj", "{17EA5194-BBE8-4CE1-B6F9-DF6829622F38}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Elsa", "modules\elsa\LINGYUN.Abp.Elsa\LINGYUN.Abp.Elsa.csproj", "{17EA5194-BBE8-4CE1-B6F9-DF6829622F38}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Elsa.Server", "modules\elsa\LINGYUN.Abp.Elsa.Server\LINGYUN.Abp.Elsa.Server.csproj", "{88AA0D46-597E-4969-8382-A3F8054B9409}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Elsa.Server", "modules\elsa\LINGYUN.Abp.Elsa.Server\LINGYUN.Abp.Elsa.Server.csproj", "{88AA0D46-597E-4969-8382-A3F8054B9409}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Elsa.EntityFramework.Core", "modules\elsa\LINGYUN.Abp.Elsa.EntityFramework.Core\LINGYUN.Abp.Elsa.EntityFramework.Core.csproj", "{CAC0D3A2-8BFA-4A84-A7FA-550A3BB16288}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Elsa.EntityFramework.Core", "modules\elsa\LINGYUN.Abp.Elsa.EntityFramework.Core\LINGYUN.Abp.Elsa.EntityFramework.Core.csproj", "{CAC0D3A2-8BFA-4A84-A7FA-550A3BB16288}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Elsa.Activities.BlobStoring", "modules\elsa\LINGYUN.Abp.Elsa.Activities.BlobStoring\LINGYUN.Abp.Elsa.Activities.BlobStoring.csproj", "{81CB5141-4FC5-413A-A516-CD65F40465C0}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -143,6 +145,14 @@ Global {CAC0D3A2-8BFA-4A84-A7FA-550A3BB16288}.Debug|Any CPU.Build.0 = Debug|Any CPU {CAC0D3A2-8BFA-4A84-A7FA-550A3BB16288}.Release|Any CPU.ActiveCfg = Release|Any CPU {CAC0D3A2-8BFA-4A84-A7FA-550A3BB16288}.Release|Any CPU.Build.0 = Release|Any CPU + {81CB5141-4FC5-413A-A516-CD65F40465C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81CB5141-4FC5-413A-A516-CD65F40465C0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81CB5141-4FC5-413A-A516-CD65F40465C0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81CB5141-4FC5-413A-A516-CD65F40465C0}.Release|Any CPU.Build.0 = Release|Any CPU + {00CB6328-83F0-4C50-9561-2C61AFC03CA1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00CB6328-83F0-4C50-9561-2C61AFC03CA1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00CB6328-83F0-4C50-9561-2C61AFC03CA1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00CB6328-83F0-4C50-9561-2C61AFC03CA1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -171,6 +181,8 @@ Global {17EA5194-BBE8-4CE1-B6F9-DF6829622F38} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} {88AA0D46-597E-4969-8382-A3F8054B9409} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} {CAC0D3A2-8BFA-4A84-A7FA-550A3BB16288} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} + {81CB5141-4FC5-413A-A516-CD65F40465C0} = {F1CCBEC7-ACAB-4DC5-909E-D8CC2E1B7EEC} + {00CB6328-83F0-4C50-9561-2C61AFC03CA1} = {2F51B296-58EB-4D54-9921-5A07E6E4B7BF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6BB7A5DE-DA12-44DC-BC9B-0F6CA524346F} diff --git a/aspnet-core/modules/authorization/LINGYUN.Abp.Identity.OrganizaztionUnits/LINGYUN/Abp/Identity/OrganizaztionUnits/OrganizationUnitClaimsPrincipalContributor.cs b/aspnet-core/modules/authorization/LINGYUN.Abp.Identity.OrganizaztionUnits/LINGYUN/Abp/Identity/OrganizaztionUnits/OrganizationUnitClaimsPrincipalContributor.cs index 9854e9c38..2418ecd6e 100644 --- a/aspnet-core/modules/authorization/LINGYUN.Abp.Identity.OrganizaztionUnits/LINGYUN/Abp/Identity/OrganizaztionUnits/OrganizationUnitClaimsPrincipalContributor.cs +++ b/aspnet-core/modules/authorization/LINGYUN.Abp.Identity.OrganizaztionUnits/LINGYUN/Abp/Identity/OrganizaztionUnits/OrganizationUnitClaimsPrincipalContributor.cs @@ -34,7 +34,7 @@ public class OrganizationUnitClaimsPrincipalContributor : IAbpClaimsPrincipalCon return; } - var userOus = await _identityUserRepository.GetOrganizationUnitsAsync(userId.Value); + var userOus = await _identityUserRepository.GetOrganizationUnitsAsync(id: userId.Value); foreach (var userOu in userOus) { diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Internal/NotificationSender.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Internal/NotificationSender.cs index 2dcdd021c..b4b750853 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Internal/NotificationSender.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/Internal/NotificationSender.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading.Tasks; using Volo.Abp.DependencyInjection; using Volo.Abp.EventBus.Distributed; +using Volo.Abp.Timing; using Volo.Abp.Uow; namespace LINGYUN.Abp.Notifications @@ -18,6 +19,10 @@ namespace LINGYUN.Abp.Notifications /// public class NotificationSender : INotificationSender, ITransientDependency { + /// + /// Reference to . + /// + protected IClock Clock { get; } /// /// Reference to . /// @@ -37,11 +42,13 @@ namespace LINGYUN.Abp.Notifications protected AbpNotificationOptions Options { get; } public NotificationSender( - IDistributedEventBus distributedEventBus, - IDistributedIdGenerator distributedIdGenerator, - IUnitOfWorkManager unitOfWorkManager, - IOptions options) + IClock clock, + IDistributedEventBus distributedEventBus, + IDistributedIdGenerator distributedIdGenerator, + IUnitOfWorkManager unitOfWorkManager, + IOptions options) { + Clock = clock; Options = options.Value; DistributedEventBus = distributedEventBus; DistributedIdGenerator = distributedIdGenerator; @@ -82,7 +89,7 @@ namespace LINGYUN.Abp.Notifications TenantId = tenantId, Users = users?.ToList(), Name = name, - CreationTime = DateTime.Now, + CreationTime = Clock.Now, Severity = severity }; diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/FodyWeavers.xml b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/FodyWeavers.xml new file mode 100644 index 000000000..ac6b5b292 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/FodyWeavers.xsd b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/FodyWeavers.xsd new file mode 100644 index 000000000..11da52550 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN.Abp.Elsa.Activities.BlobStoring.csproj b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN.Abp.Elsa.Activities.BlobStoring.csproj new file mode 100644 index 000000000..50596bc1a --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN.Abp.Elsa.Activities.BlobStoring.csproj @@ -0,0 +1,21 @@ + + + + + + + netstandard2.1 + + Enable + + + + + + + + + + + + diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/AbpElsaActivitiesBlobStoringModule.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/AbpElsaActivitiesBlobStoringModule.cs new file mode 100644 index 000000000..459f0ede0 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/AbpElsaActivitiesBlobStoringModule.cs @@ -0,0 +1,11 @@ +using Volo.Abp.BlobStoring; +using Volo.Abp.Modularity; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; + +[DependsOn( + typeof(AbpElsaModule), + typeof(AbpBlobStoringModule))] +public class AbpElsaActivitiesBlobStoringModule : AbpModule +{ +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/AbpElsaBlobContainer.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/AbpElsaBlobContainer.cs new file mode 100644 index 000000000..acbac9218 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/AbpElsaBlobContainer.cs @@ -0,0 +1,8 @@ +using Volo.Abp.BlobStoring; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; + +[BlobContainerName("elsa-container")] +public class AbpElsaBlobContainer +{ +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobExists.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobExists.cs new file mode 100644 index 000000000..321555dc6 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/BlobExists.cs @@ -0,0 +1,36 @@ +using Elsa; +using Elsa.ActivityResults; +using Elsa.Attributes; +using Elsa.Services; +using Elsa.Services.Models; +using System; +using System.Threading.Tasks; +using Volo.Abp.BlobStoring; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; + +[Action(Category = "Blob", + Description = "Check if a blob exists.", + Outcomes = new[] { OutcomeNames.True, OutcomeNames.False })] +public class BlobExists : Activity +{ + private readonly IBlobContainer _container; + + [ActivityInput(Hint = "Path of the oss.")] + public string? Path { get; set; } + + public BlobExists(IBlobContainer container) + { + _container = container; + } + + protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + { + var exists = await _container.ExistsAsync(Path, context.CancellationToken); + if (exists) + { + return Outcome(OutcomeNames.True); + } + return Outcome(OutcomeNames.False); + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/DeleteBlob.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/DeleteBlob.cs new file mode 100644 index 000000000..3f28738a5 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/DeleteBlob.cs @@ -0,0 +1,33 @@ +using Elsa; +using Elsa.ActivityResults; +using Elsa.Attributes; +using Elsa.Services; +using Elsa.Services.Models; +using System; +using System.Threading.Tasks; +using Volo.Abp.BlobStoring; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; + +[Action(Category = "Blob", + Description = "Deletes blob at specified location", + Outcomes = new[] { OutcomeNames.Done })] +public class DeleteBlob : Activity +{ + private readonly IBlobContainer _container; + + [ActivityInput(Hint = "Path of the blob to be deleted.")] + public string? Path { get; set; } + + public DeleteBlob(IBlobContainer container) + { + _container = container; + } + + protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + { + await _container.DeleteAsync(Path, context.CancellationToken); + + return Done(); + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/ReadBlob.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/ReadBlob.cs new file mode 100644 index 000000000..7672ddd0b --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/ReadBlob.cs @@ -0,0 +1,36 @@ +using Elsa; +using Elsa.ActivityResults; +using Elsa.Attributes; +using Elsa.Services; +using Elsa.Services.Models; +using System; +using System.Threading.Tasks; +using Volo.Abp.BlobStoring; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; + +[Action(Category = "Blob", + Description = "Reads a blob.", + Outcomes = new[] { OutcomeNames.Done })] +public class ReadBlob : Activity +{ + private readonly IBlobContainer _container; + + [ActivityInput(Hint = "Path of the blob.")] + public string? Path { get; set; } + + [ActivityOutput] + public byte[]? Output { get; set; } + + public ReadBlob(IBlobContainer container) + { + _container = container; + } + + protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + { + Output = await _container.GetAllBytesAsync(Path, context.CancellationToken); + + return Done(); + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/WriteBlob.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/WriteBlob.cs new file mode 100644 index 000000000..65367c7da --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Activities/WriteBlob.cs @@ -0,0 +1,40 @@ +using Elsa; +using Elsa.ActivityResults; +using Elsa.Attributes; +using Elsa.Expressions; +using Elsa.Services; +using Elsa.Services.Models; +using System; +using System.Threading.Tasks; +using Volo.Abp.BlobStoring; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; + +[Action(Category = "Blob", + Description = "Save a blob.", + Outcomes = new[] { OutcomeNames.Done })] +public class WriteBlob : Activity +{ + private readonly IBlobContainer _container; + + [ActivityInput(Hint = "Path of the blob.")] + public string? Path { get; set; } + + [ActivityInput(Hint = "Blob exists whether overwrite")] + public bool Overwrite { get; set; } + + [ActivityInput(Hint = "The bytes to write.", SupportedSyntaxes = new[] { SyntaxNames.JavaScript }, DefaultSyntax = SyntaxNames.JavaScript)] + public byte[]? Bytes { get; set; } + + public WriteBlob(IBlobContainer container) + { + _container = container; + } + + protected async override ValueTask OnExecuteAsync(ActivityExecutionContext context) + { + await _container.SaveAsync(Path, Bytes, Overwrite, context.CancellationToken); + + return Done(); + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Startup.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Startup.cs new file mode 100644 index 000000000..a07f3ff6f --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/LINGYUN/Abp/Elsa/Activities/BlobStoring/Startup.cs @@ -0,0 +1,16 @@ +using Elsa.Attributes; +using Elsa.Options; +using Elsa.Services.Startup; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace LINGYUN.Abp.Elsa.Activities.BlobStoring; + +[Feature("BlobStoring")] +public class Startup : StartupBase +{ + public override void ConfigureElsa(ElsaOptionsBuilder elsa, IConfiguration configuration) + { + elsa.AddBlobStoringActivities(); + } +} diff --git a/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/Microsoft/Extensions/DependencyInjection/BlobStoringServiceCollectionExtensions.cs b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/Microsoft/Extensions/DependencyInjection/BlobStoringServiceCollectionExtensions.cs new file mode 100644 index 000000000..7de227477 --- /dev/null +++ b/aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.Activities.BlobStoring/Microsoft/Extensions/DependencyInjection/BlobStoringServiceCollectionExtensions.cs @@ -0,0 +1,18 @@ +using Elsa.Options; +using LINGYUN.Abp.Elsa.Activities.BlobStoring; + +namespace Microsoft.Extensions.DependencyInjection; + +public static class BlobStoringServiceCollectionExtensions +{ + public static ElsaOptionsBuilder AddBlobStoringActivities(this ElsaOptionsBuilder options) + { + options + .AddActivity() + .AddActivity() + .AddActivity() + .AddActivity(); + + return options; + } +} diff --git a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitPermissionManagementProvider.cs b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitPermissionManagementProvider.cs index a52317dc0..a28327563 100644 --- a/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitPermissionManagementProvider.cs +++ b/aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.Domain.OrganizationUnits/LINGYUN/Abp/PermissionManagement/OrganizationUnits/OrganizationUnitPermissionManagementProvider.cs @@ -68,7 +68,7 @@ public class OrganizationUnitPermissionManagementProvider : PermissionManagement if (providerName == UserPermissionValueProvider.ProviderName) { var userId = Guid.Parse(providerKey); - var organizationUnits = await IdentityUserRepository.GetOrganizationUnitsAsync(userId); + var organizationUnits = await IdentityUserRepository.GetOrganizationUnitsAsync(id: userId); foreach (var organizationUnit in organizationUnits) { diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs index 08bef0bfb..e96f0996b 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/EventBus/Distributed/NotificationEventHandler.cs @@ -134,11 +134,11 @@ namespace LY.MicroService.RealtimeMessage.EventBus.Distributed cultureName: eventData.Data.Culture, globalContext: new Dictionary { - { "notification", notification.Name }, - { "formUser", eventData.Data.FormUser }, - { "notificationId", eventData.Id }, - { "title", title.ToString() }, - { "creationTime", eventData.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") }, + { "$notification", notification.Name }, + { "$formUser", eventData.Data.FormUser }, + { "$notificationId", eventData.Id }, + { "$title", title.ToString() }, + { "$creationTime", eventData.CreationTime.ToString("yyyy-MM-dd HH:mm:ss") }, }); var notificationData = new NotificationData(); diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj index c3a21c215..65dfdb07d 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/LY.MicroService.WorkflowManagement.HttpApi.Host.csproj @@ -11,9 +11,10 @@ - + all @@ -45,6 +46,7 @@ + diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Pages/_Host.cshtml b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Pages/_Host.cshtml index 5352f8b1e..0a576edef 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Pages/_Host.cshtml +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Pages/_Host.cshtml @@ -1,6 +1,8 @@ @page "/" +@inject IConfiguration Configuration; @{ - var serverUrl = $"{Request.Scheme}://{Request.Host}"; + var serverUrl = Configuration["Elsa:Server:BaseAddress"]; + var basePath = Configuration["Hosting:BasePath"]; } @@ -8,16 +10,32 @@ Elsa Workflows - - - - - - + + + + + + + - + + + + \ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Pages/_ViewImports.cshtml b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Pages/_ViewImports.cshtml new file mode 100644 index 000000000..72a8451ae --- /dev/null +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/Pages/_ViewImports.cshtml @@ -0,0 +1,2 @@ +@using Microsoft.Extensions.Configuration +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers \ No newline at end of file diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs index 6a54425fa..25d663d50 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs @@ -1,6 +1,6 @@ using Elsa; -using Elsa.Activities.UserTask.Extensions; using Elsa.Options; +using Elsa.Rebus.RabbitMq; using LINGYUN.Abp.BlobStoring.OssManagement; using LINGYUN.Abp.ExceptionHandling; using LINGYUN.Abp.ExceptionHandling.Emailing; @@ -10,6 +10,7 @@ using Medallion.Threading; using Medallion.Threading.Redis; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.Routing; using Microsoft.EntityFrameworkCore; @@ -19,9 +20,11 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.OpenApi.Models; using StackExchange.Redis; using System; +using System.Linq; using System.Text.Encodings.Web; using System.Text.Unicode; using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc.AntiForgery; using Volo.Abp.Auditing; using Volo.Abp.BlobStoring; using Volo.Abp.Caching; @@ -38,6 +41,8 @@ namespace LY.MicroService.WorkflowManagement; public partial class WorkflowManagementHttpApiHostModule { + private const string DefaultCorsPolicyName = "Default"; + private const string ApplicationName = "WorkflowManagement"; private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); private void PreConfigureFeature() @@ -50,37 +55,46 @@ public partial class WorkflowManagementHttpApiHostModule private void PreConfigureApp() { - AbpSerilogEnrichersConsts.ApplicationName = "WorkflowManagement"; + AbpSerilogEnrichersConsts.ApplicationName = ApplicationName; } private void PreConfigureElsa(IServiceCollection services, IConfiguration configuration) { var elsaSection = configuration.GetSection("Elsa"); + var startups = new[] + { + typeof(Elsa.Activities.Console.Startup), + typeof(Elsa.Activities.Http.Startup), + typeof(Elsa.Activities.UserTask.Startup), + typeof(Elsa.Activities.Temporal.Quartz.Startup), + typeof(Elsa.Activities.Email.Startup), + typeof(Elsa.Persistence.EntityFramework.MySql.Startup), + typeof(Elsa.Scripting.JavaScript.Startup), + typeof(Elsa.Activities.Webhooks.Startup), + typeof(Elsa.Webhooks.Persistence.EntityFramework.MySql.Startup), + typeof(Elsa.WorkflowSettings.Persistence.EntityFramework.MySql.Startup), + typeof(LINGYUN.Abp.Elsa.Activities.BlobStoring.Startup), + }; - PreConfigure(builder => + PreConfigure(elsa => { - // TODO: 取消注释持久化 - //var connectionString = configuration.GetConnectionString("Workflow"); - //builder.UseEntityFrameworkPersistence(ef => - // ef.UseMySql(connectionString)); - builder.AddQuartzTemporalActivities() - .AddEmailActivities() - .AddUserTaskActivities() - .AddHttpActivities(elsaSection.GetSection("Server").Bind) - .AddWorkflowsFrom(); - //.AddWorkflowSettings() - //.AddWebhooks(options => - //{ - // options.UseEntityFrameworkPersistence(db => - // { - // db.UseMySql(configuration.GetConnectionString("Workflow")); - // }); - //}) - //.UseEntityFrameworkPersistence(db => - //{ - // db.UseMySql(configuration.GetConnectionString("Workflow")); - //}); + elsa + .AddActivitiesFrom() + .AddWorkflowsFrom() + .AddFeatures(startups, configuration) + .ConfigureWorkflowChannels(options => elsaSection.GetSection("WorkflowChannels").Bind(options)) + .UseRabbitMq(elsaSection["Rebus:RabbitMQ:Connection"]); + + elsa.DistributedLockingOptionsBuilder + .UseProviderFactory(sp => name => + { + var provider = sp.GetRequiredService(); + + return provider.CreateLock(name); + }); }); + + services.AddNotificationHandlersFrom(); } private void ConfigureEndpoints() @@ -174,7 +188,7 @@ public partial class WorkflowManagementHttpApiHostModule { Configure(options => { - options.ApplicationName = "WorkflowManagement"; + options.ApplicationName = ApplicationName; // 是否启用实体变更记录 var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get()) @@ -294,6 +308,12 @@ public partial class WorkflowManagementHttpApiHostModule private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) { + Configure(options => + { + options.AutoValidate = false; + //options.AutoValidateFilter = (type) => !type.Namespace.Contains("elsa", StringComparison.CurrentCultureIgnoreCase); + }); + services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { @@ -316,4 +336,27 @@ public partial class WorkflowManagementHttpApiHostModule .PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); } } + + private void ConfigureCors(IServiceCollection services, IConfiguration configuration) + { + services.AddCors(options => + { + options.AddPolicy(DefaultCorsPolicyName, builder => + { + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .WithExposedHeaders("_AbpWrapResult", "_AbpDontWrapResult") + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); + }); + }); + } } diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs index 5ae2dcb1c..47ecac401 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs @@ -27,6 +27,8 @@ using Volo.Abp.Modularity; using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.Swashbuckle; +using LINGYUN.Abp.Elsa.Activities.BlobStoring; +using Elsa; namespace LY.MicroService.WorkflowManagement; @@ -38,14 +40,7 @@ namespace LY.MicroService.WorkflowManagement; typeof(AbpBlobStoringOssManagementModule), typeof(AbpElsaModule), typeof(AbpElsaServerModule), - //typeof(WorkflowManagementApplicationModule), - //typeof(WorkflowManagementHttpApiModule), - //typeof(WorkflowManagementEntityFrameworkCoreModule), - //typeof(AbpWorkflowCoreComponentsModule), - //typeof(AbpWorkflowCoreDistributedLockModule), - //typeof(AbpWorkflowCoreLifeCycleEventModule), - //typeof(AbpWorkflowCoreRabbitMQModule), - //typeof(AbpWorkflowCorePersistenceEntityFrameworkCoreModule), + typeof(AbpElsaActivitiesBlobStoringModule), typeof(AbpEntityFrameworkCoreMySQLModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpEmailingExceptionHandlingModule), @@ -90,6 +85,7 @@ public partial class WorkflowManagementHttpApiHostModule : AbpModule ConfigureAuditing(configuration); ConfigureMultiTenancy(configuration); ConfigureSwagger(context.Services); + ConfigureCors(context.Services, configuration); ConfigureBlobStoring(context.Services, configuration); ConfigureDistributedLock(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); @@ -107,7 +103,8 @@ public partial class WorkflowManagementHttpApiHostModule : AbpModule app.UseHttpActivities(); app.UseCorrelationId(); app.UseRouting(); - app.UseCors(); + app.UseCors(DefaultCorsPolicyName); + app.UseElsaFeatures(); app.UseAuthentication(); app.UseJwtTokenMiddleware(); app.UseMultiTenancy(); diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.Development.json b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.Development.json index 1822368d9..fbf9aab36 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.Development.json +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.Development.json @@ -8,7 +8,8 @@ "tag": "LINGYUN.Abp.WorkflowManagement" }, "App": { - "TrackingEntitiesChanged": true + "TrackingEntitiesChanged": true, + "CorsOrigins": "http://127.0.0.1:3100" }, "ConnectionStrings": { "Default": "Server=127.0.0.1;Database=Workflow;User Id=root;Password=123456", @@ -22,6 +23,48 @@ "AbpSaas": "Server=127.0.0.1;Database=Platform;User Id=root;Password=123456" }, "Elsa": { + "Features": { + "DefaultPersistence": { + "ConnectionStringIdentifier": "Workflow", + "EntityFrameworkCore": { + "MySql": { + "Enabled": true + } + } + }, + "Console": true, + "Http": true, + "Email": true, + "TemporalQuartz": true, + "JavaScriptActivities": true, + "UserTask": true, + "Conductor": true, + "Telnyx": true, + "BlobStoring": true, + "Webhooks": { + "Enabled": true, + "ConnectionStringIdentifier": "Workflow", + "EntityFrameworkCore": { + "MySql": { + "Enabled": true + } + } + }, + "WorkflowSettings": { + "Enabled": true, + "ConnectionStringIdentifier": "Workflow", + "EntityFrameworkCore": { + "MySql": { + "Enabled": true + } + } + } + }, + "Rebus": { + "RabbitMQ": { + "Connection": "amqp://admin:662874@127.0.0.1:5672/" + } + }, "Server": { "BaseUrl": "http://localhost:5001" } diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.json index 67e1bc4bd..1c74e3798 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.json @@ -5,6 +5,9 @@ "DefaultSalt": "sf&5)s3#" }, "AllowedHosts": "*", + "Hosting": { + "BasePath": "" + }, "Serilog": { "MinimumLevel": { "Default": "Debug",