diff --git a/aspnet-core/.gitignore b/aspnet-core/.gitignore index a6454ea49..ed4f124ad 100644 --- a/aspnet-core/.gitignore +++ b/aspnet-core/.gitignore @@ -3,4 +3,5 @@ LocalNuget *.DotSettings.user **/*.csproj.user templates -nupkg \ No newline at end of file +nupkg +consoles \ No newline at end of file diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpEventBusLifeCycleEventHub.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpEventBusLifeCycleEventHub.cs deleted file mode 100644 index 080ce5e75..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpEventBusLifeCycleEventHub.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; -using Volo.Abp.EventBus.Distributed; -using WorkflowCore.Interface; -using EventData = WorkflowCore.Models.LifeCycleEvents.LifeCycleEvent; - -namespace LINGYUN.Abp.WorkflowCore.LifeCycleEvent -{ - public class AbpEventBusLifeCycleEventHub : ILifeCycleEventHub - { - private IDisposable _subscriber; - - private readonly IDistributedEventBus _eventBus; - private readonly ILoggerFactory _loggerFactory; - - public AbpEventBusLifeCycleEventHub( - ILoggerFactory loggerFactory, - IDistributedEventBus distributedEventBus) - { - _loggerFactory = loggerFactory; - _eventBus = distributedEventBus; - } - - public async Task PublishNotification(EventData evt) - { - await _eventBus.PublishAsync(evt); - } - - public Task Start() - { - _subscriber = _eventBus.Subscribe(new LifeCycleEventHandler( - _loggerFactory.CreateLogger())); - - return Task.CompletedTask; - } - - public Task Stop() - { - // TODO - _subscriber?.Dispose(); - - return Task.CompletedTask; - } - - public void Subscribe(Action action) - { - LifeCycleEventHandler.Subscribers.Add(action); - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpEventBusProvider.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpEventBusProvider.cs new file mode 100644 index 000000000..400bb9fa0 --- /dev/null +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpEventBusProvider.cs @@ -0,0 +1,86 @@ +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.Json; +using WorkflowCore.Interface; +using EventData = WorkflowCore.Models.LifeCycleEvents.LifeCycleEvent; + +namespace LINGYUN.Abp.WorkflowCore.LifeCycleEvent +{ + public class AbpEventBusProvider : ILifeCycleEventHub + { + private bool _started = false; + private Queue> _deferredSubscribers = new Queue>(); + + private readonly IDistributedEventBus _eventBus; + private readonly ILoggerFactory _loggerFactory; + + private readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.All, + ReferenceLoopHandling = ReferenceLoopHandling.Error, + }; + + public AbpEventBusProvider( + ILoggerFactory loggerFactory, + IDistributedEventBus distributedEventBus) + { + _loggerFactory = loggerFactory; + _eventBus = distributedEventBus; + } + + public async Task PublishNotification(EventData evt) + { + var data = evt.SerializeObject(_serializerSettings); + var wrapEvent = new LifeCycleEventWrap(data); + await _eventBus.PublishAsync(wrapEvent); + } + + public Task Start() + { + _started = true; + while (_deferredSubscribers.Count > 0) + { + var action = _deferredSubscribers.Dequeue(); + _eventBus.Subscribe((data) => + { + var unWrapData = data.Data.DeserializeObject(_serializerSettings); + action(unWrapData as EventData); + + return Task.CompletedTask; + }); + } + + return Task.CompletedTask; + } + + public Task Stop() + { + // TODO + _started = false; + + return Task.CompletedTask; + } + + public void Subscribe(Action action) + { + if (_started) + { + _eventBus.Subscribe((data) => + { + var unWrapData = data.Data.DeserializeObject(_serializerSettings); + action(unWrapData as EventData); + + return Task.CompletedTask; + }); + } + else + { + _deferredSubscribers.Enqueue(action); + } + } + } +} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpWorkflowCoreLifeCycleEventModule.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpWorkflowCoreLifeCycleEventModule.cs index 1f15011dc..6612a21b8 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpWorkflowCoreLifeCycleEventModule.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/AbpWorkflowCoreLifeCycleEventModule.cs @@ -1,8 +1,11 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.EventBus; +using Volo.Abp.Json; +using Volo.Abp.Json.SystemTextJson; using Volo.Abp.Modularity; using WorkflowCore.Interface; using WorkflowCore.Models; +using EventData = WorkflowCore.Models.LifeCycleEvents.LifeCycleEvent; namespace LINGYUN.Abp.WorkflowCore.LifeCycleEvent { @@ -12,12 +15,25 @@ namespace LINGYUN.Abp.WorkflowCore.LifeCycleEvent { public override void PreConfigureServices(ServiceConfigurationContext context) { - context.Services.AddSingleton(); - context.Services.AddSingleton(); + context.Services.AddSingleton(); + context.Services.AddSingleton(); PreConfigure(options => { - options.UseEventHub(provider => provider.GetRequiredService()); + options.UseEventHub(provider => provider.GetRequiredService()); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.UseHybridSerializer = true; + }); + + Configure(options => + { + options.UnsupportedTypes.TryAdd(); }); } } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/LifeCycleEventHandler.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/LifeCycleEventHandler.cs deleted file mode 100644 index dbffbd847..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/LifeCycleEventHandler.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Volo.Abp.EventBus.Distributed; -using EventData = WorkflowCore.Models.LifeCycleEvents.LifeCycleEvent; - -namespace LINGYUN.Abp.WorkflowCore.LifeCycleEvent -{ - public class LifeCycleEventHandler : IDistributedEventHandler - { - private readonly ILogger _logger; - - internal static readonly ICollection> Subscribers = new HashSet>(); - - public LifeCycleEventHandler( - ILogger logger) - { - _logger = logger; - } - - public Task HandleEventAsync(EventData eventData) - { - NotifySubscribers(eventData); - - return Task.CompletedTask; - } - - private void NotifySubscribers(EventData evt) - { - foreach (var subscriber in Subscribers) - { - try - { - subscriber(evt); - } - catch (Exception ex) - { - _logger.LogWarning( - default, ex, $"Error on event subscriber: {ex.Message}"); - } - } - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/LifeCycleEventWrap.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/LifeCycleEventWrap.cs new file mode 100644 index 000000000..cc1cee4dc --- /dev/null +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.LifeCycleEvent/LINGYUN/Abp/WorkflowCore/LifeCycleEvent/LifeCycleEventWrap.cs @@ -0,0 +1,12 @@ +namespace LINGYUN.Abp.WorkflowCore.LifeCycleEvent +{ + public class LifeCycleEventWrap + { + public string Data { get; set; } + public LifeCycleEventWrap() { } + public LifeCycleEventWrap(string data) + { + Data = data; + } + } +} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinition.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinition.cs deleted file mode 100644 index 73162e027..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinition.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using Volo.Abp.Domain.Entities.Auditing; -using Volo.Abp.MultiTenancy; - -namespace LINGYUN.Abp.WorkflowCore.Definitions -{ - public class WorkflowDefinition : FullAuditedAggregateRoot, IMultiTenant - { - public virtual Guid? TenantId { get; protected set; } - public string Title { get; protected set; } - public int Version { get; protected set; } - public string Description { get; protected set; } - public string Icon { get; protected set; } - public string Color { get; protected set; } - public string Group { get; protected set; } - public ICollection Nodes { get; protected set; } - public ICollection Inputs { get; protected set; } - protected WorkflowDefinition() - { - Nodes = new Collection(); - Inputs = new Collection(); - } - public WorkflowDefinition( - Guid id, - string title, - int version, - string group, - string icon, - string color, - string description = null, - Guid? tenantId = null) : base(id) - { - Title = title; - Version = version; - Group = group; - Icon = icon; - Color = color; - Description = description; - TenantId = tenantId; - - Nodes = new Collection(); - Inputs = new Collection(); - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionConditionCondition.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionConditionCondition.cs deleted file mode 100644 index 4c26893be..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionConditionCondition.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using Volo.Abp.Domain.Entities; -using Volo.Abp.MultiTenancy; - -namespace LINGYUN.Abp.WorkflowCore.Definitions -{ - public class WorkflowDefinitionConditionCondition : Entity, IMultiTenant - { - public virtual Guid? TenantId { get; protected set; } - public virtual Guid ParentId { get; protected set; } - public virtual WorkflowDefinitionConditionNode ConditionNode { get; protected set; } - public virtual string Field { get; set; } - public virtual string Operator { get; set; } - public virtual string Value { get; set; } - protected WorkflowDefinitionConditionCondition() { } - public WorkflowDefinitionConditionCondition( - Guid parentId, - string field, - string opt, - string value, - Guid? tenantId = null) - { - ParentId = parentId; - Field = field; - Operator = opt; - Value = value; - TenantId = tenantId; - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionConditionNode.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionConditionNode.cs deleted file mode 100644 index d8b8fbef9..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionConditionNode.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using Volo.Abp.Domain.Entities; -using Volo.Abp.MultiTenancy; - -namespace LINGYUN.Abp.WorkflowCore.Definitions -{ - public class WorkflowDefinitionConditionNode : Entity, IMultiTenant - { - public virtual Guid? TenantId { get; protected set; } - public virtual Guid ParentId { get; protected set; } - public virtual WorkflowDefinitionNode Node { get; protected set; } - public virtual string Label { get; protected set; } - public virtual string NodeId { get; protected set; } - public virtual ICollection Conditions { get; protected set; } - - protected WorkflowDefinitionConditionNode() - { - Conditions = new Collection(); - } - - public WorkflowDefinitionConditionNode( - Guid parentId, - string label, - string nodeId, - Guid? tenantId = null) - { - ParentId = parentId; - Label = label; - NodeId = nodeId; - TenantId = tenantId; - - Conditions = new Collection(); - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionExtensions.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionExtensions.cs deleted file mode 100644 index f89e02aab..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionExtensions.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace LINGYUN.Abp.WorkflowCore.Definitions -{ - public class WorkflowDefinitionExtensions - { - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionFormData.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionFormData.cs deleted file mode 100644 index ca7b98650..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionFormData.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using Volo.Abp.Data; -using Volo.Abp.Domain.Entities; -using Volo.Abp.MultiTenancy; - -namespace LINGYUN.Abp.WorkflowCore.Definitions -{ - public class WorkflowDefinitionFormData : Entity, IMultiTenant - { - public virtual Guid? TenantId { get; protected set; } - public virtual Guid WorkflowId { get; protected set; } - public virtual WorkflowDefinition Workflow { get; protected set; } - public virtual string Name { get; protected set; } - public virtual string Label { get; protected set; } - public virtual string Type { get; protected set; } - public virtual string Value { get; protected set; } - public virtual ExtraPropertyDictionary Styles { get; protected set; } - public virtual int? MaxLength { get; protected set; } - public virtual int? MinLength { get; protected set; } - public virtual ExtraPropertyDictionary Items { get; protected set; } - public virtual ExtraPropertyDictionary Rules { get; protected set; } - protected WorkflowDefinitionFormData() - { - Styles = new ExtraPropertyDictionary(); - Items = new ExtraPropertyDictionary(); - Rules = new ExtraPropertyDictionary(); - } - public WorkflowDefinitionFormData( - Guid workflowId, - string name, - string label, - string type, - string value, - int? minLength = null, - int? maxLength = null, - Guid? tenantId = null) - { - WorkflowId = workflowId; - Name = name; - Label = label; - Type = type; - Value = value; - MinLength = minLength; - MaxLength = maxLength; - TenantId = tenantId; - - Styles = new ExtraPropertyDictionary(); - Items = new ExtraPropertyDictionary(); - Rules = new ExtraPropertyDictionary(); - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionNode.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionNode.cs deleted file mode 100644 index fb93a2789..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionNode.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using Volo.Abp.Domain.Entities; -using Volo.Abp.MultiTenancy; - -namespace LINGYUN.Abp.WorkflowCore.Definitions -{ - public class WorkflowDefinitionNode : Entity, IMultiTenant - { - public virtual Guid? TenantId { get; protected set; } - public virtual Guid WorkflowId { get; protected set; } - public virtual WorkflowDefinition Workflow { get; protected set; } - public virtual string Key { get; protected set; } - public virtual string Title { get; protected set; } - public virtual string Position { get; protected set; } - public virtual string Type { get; protected set; } - public virtual WorkflowDefinitionStepBody StepBody { get; protected set; } - public virtual string ParentNodes { get; protected set; } - public virtual ICollection NextNodes { get; protected set; } - protected WorkflowDefinitionNode() - { - NextNodes = new Collection(); - } - public WorkflowDefinitionNode( - Guid workflowId, - string key, - string title, - int[] position, - string type, - WorkflowDefinitionStepBody stepBody, - string[] parentNodes, - Guid? tenantId = null) - { - WorkflowId = workflowId; - Key = key; - Title = title; - Position = position.JoinAsString(";"); - Type = type; - StepBody = stepBody; - ParentNodes = parentNodes.JoinAsString(";"); - TenantId = tenantId; - - NextNodes = new Collection(); - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionStepBody.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionStepBody.cs deleted file mode 100644 index e4aa96165..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Definitions/WorkflowDefinitionStepBody.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Volo.Abp.Data; -using Volo.Abp.Domain.Entities; -using Volo.Abp.MultiTenancy; - -namespace LINGYUN.Abp.WorkflowCore.Definitions -{ - public class WorkflowDefinitionStepBody : Entity, IMultiTenant, IHasExtraProperties - { - public virtual Guid? TenantId { get; protected set; } - public virtual string Name { get; protected set; } - public ExtraPropertyDictionary ExtraProperties { get; protected set; } - protected WorkflowDefinitionStepBody() - { - ExtraProperties = new ExtraPropertyDictionary(); - this.SetDefaultsForExtraProperties(); - } - public WorkflowDefinitionStepBody( - Guid id, - string name) : base(id) - { - Name = name; - - ExtraProperties = new ExtraPropertyDictionary(); - this.SetDefaultsForExtraProperties(); - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Persistence/AbpWorkflowCorePersistenceModule.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Persistence/AbpWorkflowCorePersistenceModule.cs index ac147ddb6..7ce178b52 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Persistence/AbpWorkflowCorePersistenceModule.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Persistence/AbpWorkflowCorePersistenceModule.cs @@ -1,9 +1,22 @@ -using Volo.Abp.Modularity; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; +using WorkflowCore.Interface; +using WorkflowCore.Models; namespace LINGYUN.Abp.WorkflowCore.Persistence { [DependsOn(typeof(AbpWorkflowCoreModule))] public class AbpWorkflowCorePersistenceModule : AbpModule { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddSingleton(); + context.Services.AddSingleton(); + + PreConfigure(options => + { + options.UsePersistence(provider => provider.GetRequiredService()); + }); + } } } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Persistence/WorkflowDbProperties.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Persistence/WorkflowDbProperties.cs index a35d7de88..f27a245fd 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Persistence/WorkflowDbProperties.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.Persistence/LINGYUN/Abp/WorkflowCore/Persistence/WorkflowDbProperties.cs @@ -2,7 +2,7 @@ { public static class WorkflowDbProperties { - public const string ConnectionStringName = "WorkflowCore"; + public const string ConnectionStringName = "AbpWorkflowCore"; public static string TablePrefix = "WF_"; } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpRabbitMQWorkflowCoreOptions.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpRabbitMQWorkflowCoreOptions.cs index 30883e94b..f78894e1d 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpRabbitMQWorkflowCoreOptions.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpRabbitMQWorkflowCoreOptions.cs @@ -7,9 +7,20 @@ /// public string DefaultQueueNamePrefix { get; set; } + /// + /// Default value: "AbpWorkflowCore". + /// + public string DefaultConnectionName { get; set; } + /// + /// Default valu: "AbpWorkflowCore" + /// + public string DefaultChannelName { get; set; } + public AbpRabbitMQWorkflowCoreOptions() { DefaultQueueNamePrefix = "AbpWorkflows."; + DefaultConnectionName = "AbpWorkflowCore"; + DefaultChannelName = "AbpWorkflowCore"; } } } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpRabbitMqQueueProvider.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpRabbitMqQueueProvider.cs index 6267420e3..c6580fb61 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpRabbitMqQueueProvider.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpRabbitMqQueueProvider.cs @@ -1,4 +1,6 @@ -using Microsoft.Extensions.Options; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using RabbitMQ.Client; using System.Text; using System.Threading; @@ -12,7 +14,6 @@ namespace LINGYUN.Abp.WorkflowCore.RabbitMQ { public class AbpRabbitMqQueueProvider : IQueueProvider { - private string ChannelPrefix = "WorkflowQueue."; protected bool IsDiposed { get; private set; } protected SemaphoreSlim SyncObj = new SemaphoreSlim(1, 1); @@ -21,7 +22,8 @@ namespace LINGYUN.Abp.WorkflowCore.RabbitMQ protected IChannelPool ChannelPool { get; } protected IQueueNameNormalizer QueueNameNormalizer { get; } protected AbpRabbitMQWorkflowCoreOptions RabbitMQWorkflowCoreOptions { get; } - protected WorkflowQueueConfiguration QueueConfiguration { get; } + + public ILogger Logger { get; set; } public bool IsDequeueBlocking => false; @@ -34,22 +36,17 @@ namespace LINGYUN.Abp.WorkflowCore.RabbitMQ QueueNameNormalizer = queueNameNormalizer; RabbitMQWorkflowCoreOptions = options.Value; - QueueConfiguration = GetOrCreateWorkflowQueueConfiguration(); - } - - protected virtual WorkflowQueueConfiguration GetOrCreateWorkflowQueueConfiguration() - { - return new WorkflowQueueConfiguration( - RabbitMQWorkflowCoreOptions.DefaultQueueNamePrefix + "Workflow-Core", - durable: true, - exclusive: false, - autoDelete: false); + Logger = NullLogger.Instance; } public async Task DequeueWork(QueueType queue, CancellationToken cancellationToken) { + CheckDisposed(); + using (await SyncObj.LockAsync(cancellationToken)) { + await EnsureInitializedAsync(); + ChannelAccessor.Channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false); var msg = ChannelAccessor.Channel.BasicGet(QueueNameNormalizer.NormalizeKey(queue), false); @@ -65,8 +62,12 @@ namespace LINGYUN.Abp.WorkflowCore.RabbitMQ public async Task QueueWork(string id, QueueType queue) { + CheckDisposed(); + using (await SyncObj.LockAsync()) { + await EnsureInitializedAsync(); + var body = Encoding.UTF8.GetBytes(id); ChannelAccessor.Channel.BasicPublish( @@ -117,13 +118,29 @@ namespace LINGYUN.Abp.WorkflowCore.RabbitMQ } ChannelAccessor = ChannelPool.Acquire( - ChannelPrefix + QueueConfiguration.QueueName, - QueueConfiguration.ConnectionName + RabbitMQWorkflowCoreOptions.DefaultChannelName, + RabbitMQWorkflowCoreOptions.DefaultConnectionName ); + CreateDeclareWorkflowQueue(QueueType.Event); + CreateDeclareWorkflowQueue(QueueType.Workflow); + CreateDeclareWorkflowQueue(QueueType.Index); + return Task.CompletedTask; } + protected virtual void CreateDeclareWorkflowQueue(QueueType queue) + { + var queueName = QueueNameNormalizer.NormalizeKey(queue); + var configuration = new WorkflowQueueConfiguration( + queueName: queueName, + durable: true, + exclusive: false, + autoDelete: false); + + configuration.Declare(ChannelAccessor.Channel); + } + protected void CheckDisposed() { if (IsDiposed) diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpWorkflowCoreRabbitMQModule.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpWorkflowCoreRabbitMQModule.cs index 148869d6e..adda074f2 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpWorkflowCoreRabbitMQModule.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/AbpWorkflowCoreRabbitMQModule.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; using Volo.Abp.Modularity; using Volo.Abp.RabbitMQ; using WorkflowCore.Interface; @@ -20,5 +21,12 @@ namespace LINGYUN.Abp.WorkflowCore.RabbitMQ options.UseQueueProvider(provider => provider.GetRequiredService()); }); } + + public override void OnApplicationShutdown(ApplicationShutdownContext context) + { + context.ServiceProvider + .GetRequiredService() + .Dispose(); + } } } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/QueueNameNormalizer.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/QueueNameNormalizer.cs index 94e229e18..22a6ac98f 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/QueueNameNormalizer.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/QueueNameNormalizer.cs @@ -1,20 +1,29 @@ -using Volo.Abp.DependencyInjection; +using Microsoft.Extensions.Options; +using Volo.Abp.DependencyInjection; using WorkflowCore.Interface; namespace LINGYUN.Abp.WorkflowCore.RabbitMQ { public class QueueNameNormalizer : IQueueNameNormalizer, ISingletonDependency { + protected AbpRabbitMQWorkflowCoreOptions RabbitMQWorkflowCoreOptions { get; } + + public QueueNameNormalizer( + IOptions options) + { + RabbitMQWorkflowCoreOptions = options.Value; + } + public string NormalizeKey(QueueType queue) { switch (queue) { case QueueType.Workflow: - return "wfc.workflow_queue"; + return RabbitMQWorkflowCoreOptions.DefaultQueueNamePrefix + "wfc.workflow_queue"; case QueueType.Event: - return "wfc.event_queue"; + return RabbitMQWorkflowCoreOptions.DefaultQueueNamePrefix + "wfc.event_queue"; case QueueType.Index: - return "wfc.index_queue"; + return RabbitMQWorkflowCoreOptions.DefaultQueueNamePrefix + "wfc.index_queue"; default: return null; } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/WorkflowQueueConfiguration.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/WorkflowQueueConfiguration.cs index 0865616fc..8d5d2590c 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/WorkflowQueueConfiguration.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore.RabbitMQ/LINGYUN/Abp/WorkflowCore/RabbitMQ/WorkflowQueueConfiguration.cs @@ -4,18 +4,14 @@ namespace LINGYUN.Abp.WorkflowCore.RabbitMQ { public class WorkflowQueueConfiguration : QueueDeclareConfiguration { - public string ConnectionName { get; set; } - public WorkflowQueueConfiguration( string queueName, - string connectionName = null, bool durable = true, bool exclusive = false, bool autoDelete = false, string deadLetterQueueName = null) : base(queueName, durable, exclusive, autoDelete, deadLetterQueueName) { - ConnectionName = connectionName; } } } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/AbpWorkflowCoreModule.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/AbpWorkflowCoreModule.cs index 72f746261..918acdf62 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/AbpWorkflowCoreModule.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/AbpWorkflowCoreModule.cs @@ -1,8 +1,10 @@ using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; +using Volo.Abp; using Volo.Abp.Modularity; using WorkflowCore.Interface; +using WorkflowCore.Services; namespace LINGYUN.Abp.WorkflowCore { @@ -22,23 +24,24 @@ namespace LINGYUN.Abp.WorkflowCore context.Services.ExecutePreConfiguredActions(options); }); context.Services.AddWorkflowDSL(); + //context.Services.AddHostedService((provider) => provider.GetRequiredService()); } - public override void OnApplicationInitialization(Volo.Abp.ApplicationInitializationContext context) + public override void OnApplicationInitialization(ApplicationInitializationContext context) { var workflowRegistry = context.ServiceProvider.GetRequiredService(); foreach (var definitionWorkflow in _definitionWorkflows) { var workflow = context.ServiceProvider.GetRequiredService(definitionWorkflow); - workflowRegistry.RegisterWorkflow(workflow as IWorkflow); + workflowRegistry.RegisterWorkflow(workflow as WorkflowBase); } var workflowHost = context.ServiceProvider.GetRequiredService(); workflowHost.Start(); } - public override void OnApplicationShutdown(Volo.Abp.ApplicationShutdownContext context) + public override void OnApplicationShutdown(ApplicationShutdownContext context) { var workflowHost = context.ServiceProvider.GetRequiredService(); workflowHost.Stop(); diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowBase.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowBase.cs index 4b694e01a..46bcbec89 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowBase.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowBase.cs @@ -1,14 +1,14 @@ -using WorkflowCore.Interface; -using Volo.Abp.DependencyInjection; +using Volo.Abp.DependencyInjection; +using WorkflowCore.Interface; namespace LINGYUN.Abp.WorkflowCore { - public abstract class WorkflowBase : IWorkflow, ISingletonDependency + public abstract class WorkflowBase : IWorkflow, ISingletonDependency { public abstract string Id { get; } public abstract int Version { get; } - public abstract void Build(IWorkflowBuilder builder); + public abstract void Build(IWorkflowBuilder builder); } } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowConditionCondition.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowConditionCondition.cs deleted file mode 100644 index bcfb674dc..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowConditionCondition.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace LINGYUN.Abp.WorkflowCore -{ - public class WorkflowConditionCondition - { - public string Field { get; set; } - public string Operator { get; set; } - public object Value { get; set; } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowConditionNode.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowConditionNode.cs deleted file mode 100644 index 5a78cf224..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowConditionNode.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; - -namespace LINGYUN.Abp.WorkflowCore -{ - public class WorkflowConditionNode - { - public string Label { get; set; } - public string NodeId { get; set; } - public IEnumerable Conditions { get; set; } - public WorkflowConditionNode() - { - Conditions = new List(); - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowDefine.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowDefine.cs new file mode 100644 index 000000000..48424bc24 --- /dev/null +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowDefine.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace LINGYUN.Abp.WorkflowCore +{ + public class WorkflowDefine + { + public string Id { get; set; } + public int Version { get; set; } + public string Name { get; set; } + public Type DataType { get; set; } + public List Steps { get; set; } + public WorkflowDefine() + { + Steps = new List(); + } + } +} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowDefinition.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowDefinition.cs deleted file mode 100644 index c62501d2e..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowDefinition.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Collections.Generic; - -namespace LINGYUN.Abp.WorkflowCore -{ - public class WorkflowDefinition - { - public string Id { get; set; } - public string Title { get; set; } - public int Version { get; set; } - public string Description { get; set; } - public string Icon { get; set; } - public string Color { get; set; } - public string Group { get; set; } - public ICollection Nodes { get; set; } - public ICollection Inputs { get; set; } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowFormData.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowFormData.cs deleted file mode 100644 index 7de0584ec..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowFormData.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections.Generic; - -namespace LINGYUN.Abp.WorkflowCore -{ - public class WorkflowFormData - { - public string Id { get; set; } - public string Name { get; set; } - public string Label { get; set; } - public string Type { get; set; } - public object Value { get; set; } - public IEnumerable Styles { get; set; } - public int? MaxLength { get; set; } - public int? MinLength { get; set; } - public IEnumerable Items { get; set; } - public IEnumerable Rules { get; set; } - public WorkflowFormData() - { - Styles = new List(); - Items = new List(); - Rules =new List(); - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowManager.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowManager.cs deleted file mode 100644 index 7ddc88a2e..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowManager.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Volo.Abp; -using WorkflowCore.Interface; -using WorkflowCore.Models.DefinitionStorage.v1; -using WorkflowCore.Services.DefinitionStorage; -using WDF = WorkflowCore.Models.WorkflowDefinition; - -namespace LINGYUN.Abp.WorkflowCore -{ - public class WorkflowManager : IWorkflowManager - { - private readonly IWorkflowRegistry _workflowRegistry; - private readonly IDefinitionLoader _definitionLoader; - - protected IReadOnlyCollection _stepBodys; - - internal void Initlize() - { - - } - - public WDF BuildWorkflow(WorkflowDefinition definition) - { - if (_workflowRegistry.IsRegistered(definition.Id, definition.Version)) - { - throw new AbpException($"Workflow {definition.Id} has ben registered!"); - } - - var definitionSource = new DefinitionSourceV1() - { - Id = definition.Id, - Version = definition.Version, - DataType = $"{typeof(Dictionary).FullName}, {typeof(Dictionary).Assembly.FullName}", - Description = definition.Title, - }; - - BuildWorkflow(definition.Nodes, definitionSource, _stepBodys, definition.Nodes.First(u => u.Key.ToLower().StartsWith("start"))); - var json = definitionSource.SerializeObject(); - var def = _definitionLoader.LoadDefinition(json, Deserializers.Json); - return def; - } - - protected virtual void BuildWorkflow(IEnumerable allNodes, DefinitionSourceV1 source, IEnumerable stepBodys, WorkflowNode node) - { - if (source.Steps.Any(u => u.Id == node.Key)) - { - return; - } - - var stepSource = new StepSourceV1 - { - Id = node.Key, - Name = node.Key - }; - WorkflowStepBody stepbody = stepBodys.FirstOrDefault(u => u.Name == node.StepBody.Name); - if (stepbody == null) - { - stepbody = new WorkflowStepBody() { StepBodyType = typeof(NullStepBody) }; - } - stepSource.StepType = $"{stepbody.StepBodyType.FullName}, {stepbody.StepBodyType.Assembly.FullName}"; - - foreach (var input in stepbody.Inputs) - { - var value = node.StepBody.Inputs[input.Key].Value; - if (!(value is IDictionary || value is IDictionary)) - { - value = $"\"{value}\""; - } - stepSource.Inputs.AddIfNotContains(new KeyValuePair(input.Key, value)); - } - source.Steps.Add(stepSource); - BuildBranching(allNodes, source, stepSource, stepBodys, node.NextNodes); - } - protected virtual void BuildBranching(IEnumerable allNodes, DefinitionSourceV1 source, StepSourceV1 stepSource, IEnumerable stepBodys, IEnumerable nodes) - { - foreach (var nextNode in nodes) - { - var node = allNodes.First(u => u.Key == nextNode.NodeId); - stepSource.SelectNextStep[nextNode.NodeId] = "1==1"; - if (nextNode.Conditions.Count() > 0) - { - List exps = new List(); - foreach (var cond in nextNode.Conditions) - { - if (cond.Value is string && (!decimal.TryParse(cond.Value.ToString(), out decimal tempValue))) - { - if (cond.Operator != "==" && cond.Operator != "!=") - { - throw new AbpException($" if {cond.Field} is type of 'String', the Operator must be \"==\" or \"!=\""); - } - exps.Add($"data[\"{cond.Field}\"].ToString() {cond.Operator} \"{cond.Value}\""); - continue; - } - exps.Add($"decimal.Parse(data[\"{cond.Field}\"].ToString()) {cond.Operator} {cond.Value}"); - } - stepSource.SelectNextStep[nextNode.NodeId] = string.Join(" && ", exps); - } - - BuildWorkflow(allNodes, source, stepBodys, node); - } - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowNode.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowNode.cs deleted file mode 100644 index 0a61cbc5e..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowNode.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections.Generic; - -namespace LINGYUN.Abp.WorkflowCore -{ - public class WorkflowNode - { - public string Key { get; set; } - public string Title { get; set; } - public int[] Position { get; set; } - public string Type { get; set; } - public WorkflowStepBody StepBody { get; set; } - public IEnumerable ParentNodes { get; set; } - public IEnumerable NextNodes { get; set; } - public WorkflowNode() - { - StepBody = new WorkflowStepBody(); - NextNodes = new List(); - } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowParam.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowParam.cs deleted file mode 100644 index 62b81439b..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowParam.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace LINGYUN.Abp.WorkflowCore -{ - public class WorkflowParam - { - public string Name { get; set; } - public string DisplayName { get; set; } - public string InputType { get; set; } - public object Value { get; set; } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowParamDictionary.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowParamDictionary.cs deleted file mode 100644 index 0188fb1ec..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowParamDictionary.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Collections.Generic; - -namespace LINGYUN.Abp.WorkflowCore -{ - public class WorkflowParamDictionary : Dictionary - { - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowParamInput.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowParamInput.cs deleted file mode 100644 index 5bd1058db..000000000 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowParamInput.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace LINGYUN.Abp.WorkflowCore -{ - public class WorkflowParamInput - { - public string Name { get; set; } - public object Value { get; set; } - } -} diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowStepBody.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowStepBody.cs index f4ce9cbd1..e9c33dca9 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowStepBody.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/LINGYUN/Abp/WorkflowCore/WorkflowStepBody.cs @@ -1,17 +1,31 @@ using System; using System.Collections.Generic; +using WorkflowCore.Models; namespace LINGYUN.Abp.WorkflowCore { public class WorkflowStepBody { + public string Id { get; set; } public string Name { get; set; } - public Type StepBodyType { get; set; } + public Type StepType { get; set; } + public bool Saga { get; set; } public string DisplayName { get; set; } - public Dictionary Inputs { get; set; } + public string NextStep { get; set; } + public string CancelCondition { get; set; } + public TimeSpan? RetryInterval { get; set; } + public WorkflowErrorHandling? ErrorBehavior { get; set; } + public List CompensateWith { get; set; } + public Dictionary Inputs { get; set; } + public Dictionary Outputs { get; set; } + public Dictionary SelectNextStep { get; set; } + public WorkflowStepBody() { - Inputs = new Dictionary(); + CompensateWith = new List(); + Inputs = new Dictionary(); + Outputs = new Dictionary(); + SelectNextStep = new Dictionary(); } } } diff --git a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/System/ObjectSerializerExtensions.cs b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/System/ObjectSerializerExtensions.cs index 3c21c9c66..898edaaf8 100644 --- a/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/System/ObjectSerializerExtensions.cs +++ b/aspnet-core/modules/workflow/LINGYUN.Abp.WorkflowCore/System/ObjectSerializerExtensions.cs @@ -6,14 +6,14 @@ namespace System { private static JsonSerializerSettings SerializerSettings = new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All }; - public static string SerializeObject(this object obj) + public static string SerializeObject(this object obj, JsonSerializerSettings serializerSettings = null) { - return JsonConvert.SerializeObject(obj, SerializerSettings); + return JsonConvert.SerializeObject(obj, serializerSettings ?? SerializerSettings); } - public static object DeserializeObject(this string str) + public static object DeserializeObject(this string str, JsonSerializerSettings serializerSettings = null) { - return JsonConvert.DeserializeObject(str, SerializerSettings); + return JsonConvert.DeserializeObject(str, serializerSettings ?? SerializerSettings); } } } diff --git a/aspnet-core/tests/LINGYUN.Abp.WorkflowCore.Tests/LINGYUN.Abp.WorkflowCore.Tests.csproj b/aspnet-core/tests/LINGYUN.Abp.WorkflowCore.Tests/LINGYUN.Abp.WorkflowCore.Tests.csproj index c1757d1b0..80fbadbe1 100644 --- a/aspnet-core/tests/LINGYUN.Abp.WorkflowCore.Tests/LINGYUN.Abp.WorkflowCore.Tests.csproj +++ b/aspnet-core/tests/LINGYUN.Abp.WorkflowCore.Tests/LINGYUN.Abp.WorkflowCore.Tests.csproj @@ -11,6 +11,7 @@ +