Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace EasyAbp.ProcessManagement.Processes;

public interface IProcess
public interface IProcess : IProcessStateBase
{
/// <summary>
/// The hardcoded Name value from ProcessDefinition.
Expand All @@ -12,19 +12,19 @@ public interface IProcess
string ProcessName { get; }

/// <summary>
/// An unique correlation ID. If not set, this value will be auto-set to the value of the Id property.
/// A unique correlation ID. If not set, this value will be auto-set to the value of the Id property.
/// </summary>
[NotNull]
string CorrelationId { get; }

/// <summary>
/// A custom tag. It can be used for auth and filter.
/// A custom user group key. It can be used for auth and filter.
/// </summary>
/// <example>
/// {OrganizationUnitId}
/// OU:{OrganizationUnitId}
/// </example>
[CanBeNull]
string CustomTag { get; }
string GroupKey { get; }

/// <summary>
/// Record whether this process changed into a final state.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using JetBrains.Annotations;

namespace EasyAbp.ProcessManagement.Processes;

public interface IProcessState : IProcessStateBase
{
/// <summary>
/// Description for the state, optional. It supports both plain text and HTML.
/// Description for the state, optional. This value will NOT be shown in the notification list,
/// users can only view it in the detail page/modal. Both plain text and HTML are supported.
/// </summary>
/// <example><![CDATA[<p>Data is loading...</p>]]></example>
/// <example><![CDATA[<p>Data is loading, the uploader ID is...</p>]]></example>
[CanBeNull]
string StateDetailsText { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,23 @@ public interface IProcessStateBase

/// <summary>
/// A dynamic custom sub state name, optional. Users can see both the StateName and SubStateName on the UI.
/// Only plain text is supported.
/// </summary>
/// <example>Copying the data</example>
[CanBeNull]
string SubStateName { get; }

/// <summary>
/// This flag is converted to a state icon and displayed on the UI.
/// For example, when the flag is Warning, the UI shows ⚠️.
/// </summary>
ProcessStateFlag StateFlag { get; }

/// <summary>
/// Summary for the state, optional. This value will be shown in the notification list.
/// Both plain text and HTML are supported.
/// </summary>
/// <example><![CDATA[<p>Data is loading...</p>]]></example>
[CanBeNull]
string StateSummaryText { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace EasyAbp.ProcessManagement.Processes;

public enum ProcessStateFlag
{
Information,
Success,
Failure,
Running,
Question,
Warning
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using JetBrains.Annotations;
using Volo.Abp;

namespace EasyAbp.ProcessManagement.Processes;

Expand All @@ -15,6 +16,12 @@ public class ProcessStateInfoModel : IProcessState
/// <inheritdoc/>
public virtual string SubStateName { get; protected set; }

/// <inheritdoc/>
public virtual ProcessStateFlag StateFlag { get; protected set; }

/// <inheritdoc/>
public virtual string StateSummaryText { get; protected set; }

/// <inheritdoc/>
public virtual string StateDetailsText { get; protected set; }

Expand All @@ -23,11 +30,13 @@ public ProcessStateInfoModel()
}

public ProcessStateInfoModel(DateTime stateUpdateTime, [NotNull] string stateName, [CanBeNull] string subStateName,
[CanBeNull] string detailsText)
ProcessStateFlag stateFlag, [CanBeNull] string stateSummaryText, [CanBeNull] string stateDetailsText)
{
StateUpdateTime = stateUpdateTime;
StateName = stateName;
StateName = Check.NotNullOrWhiteSpace(stateName, nameof(stateName));
SubStateName = subStateName;
StateDetailsText = detailsText;
StateFlag = stateFlag;
StateSummaryText = stateSummaryText;
StateDetailsText = stateDetailsText;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(AbpVersion)" />
<PackageReference Include="Volo.Abp.Users.Abstractions" Version="$(AbpVersion)" />
<ProjectReference Include="..\EasyAbp.ProcessManagement.Domain.Shared\EasyAbp.ProcessManagement.Domain.Shared.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace EasyAbp.ProcessManagement.UserProcesses;
namespace EasyAbp.ProcessManagement.Notifications;

public class UserProcess : CreationAuditedAggregateRoot<Guid>, IProcess, IProcessStateBase, IMultiTenant
public class Notification : CreationAuditedAggregateRoot<Guid>, IProcess, IMultiTenant
{
public virtual Guid? TenantId { get; protected set; }

public virtual Guid UserId { get; protected set; }

public virtual bool Read { get; protected set; }

public virtual bool Dismissed { get; protected set; }

#region Process information

/// <inheritdoc/>
public virtual string ProcessName { get; protected set; }

/// <inheritdoc/>
public virtual string CorrelationId { get; protected set; }

/// <inheritdoc/>
public virtual string CustomTag { get; protected set; }
public virtual string GroupKey { get; protected set; }

/// <inheritdoc/>
public virtual bool IsCompleted { get; protected set; }
Expand All @@ -35,24 +41,36 @@ public class UserProcess : CreationAuditedAggregateRoot<Guid>, IProcess, IProces
/// <inheritdoc/>
public virtual string SubStateName { get; protected set; }

public UserProcess(Guid id, Process process, Guid userId) : base(id)
/// <inheritdoc/>
public virtual ProcessStateFlag StateFlag { get; protected set; }

/// <inheritdoc/>
public virtual string StateSummaryText { get; protected set; }

#endregion

public Notification(Guid id, Process process, Guid userId) : base(id)
{
TenantId = process.TenantId;
UserId = userId;

Update(process);
}

public void Update(Process process)
{
ProcessName = process.ProcessName;

CorrelationId = process.CorrelationId;
CustomTag = process.CustomTag;
GroupKey = process.GroupKey;
IsCompleted = process.IsCompleted;
CompletionTime = process.CompletionTime;

StateUpdateTime = process.StateUpdateTime;
StateName = process.StateName;
SubStateName = process.SubStateName;
StateFlag = process.StateFlag;
StateSummaryText = process.StateSummaryText;
}

public void SetAsRead(bool dismissed)
{
Read = true;
Dismissed = dismissed;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Threading.Tasks;
using EasyAbp.ProcessManagement.Processes;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.EventBus;

namespace EasyAbp.ProcessManagement.Notifications;

public class ProcessChangedEventHandler : ITransientDependency,
ILocalEventHandler<EntityCreatedEventData<Process>>,
ILocalEventHandler<EntityUpdatedEventData<Process>>,
ILocalEventHandler<EntityDeletedEventData<Process>>
{
public virtual async Task HandleEventAsync(EntityCreatedEventData<Process> eventData)
{
// todo: create notifications.
}

public virtual async Task HandleEventAsync(EntityUpdatedEventData<Process> eventData)
{
// todo: create notifications.
}

public virtual async Task HandleEventAsync(EntityDeletedEventData<Process> eventData)
{
// todo: delete notifications.
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
using Volo.Abp.Domain;
using Volo.Abp.Modularity;
using Volo.Abp.Users;

namespace EasyAbp.ProcessManagement;

[DependsOn(
typeof(AbpDddDomainModule),
typeof(AbpUsersAbstractionModule),
typeof(ProcessManagementDomainSharedModule)
)]
public class ProcessManagementDomainModule : AbpModule
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Threading.Tasks;
using EasyAbp.ProcessManagement.Processes;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus;
using Volo.Abp.Guids;

namespace EasyAbp.ProcessManagement.ProcessStateHistories;

public class ProcessStateChangedEventHandler : ILocalEventHandler<ProcessStateChangedEto>, ITransientDependency
{
private readonly IGuidGenerator _guidGenerator;

public ProcessStateChangedEventHandler(IGuidGenerator guidGenerator)
{
_guidGenerator = guidGenerator;
}

public virtual async Task HandleEventAsync(ProcessStateChangedEto eventData)
{
var history = new ProcessStateHistory(_guidGenerator.Create(), eventData.Process);

// todo: save history entity.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using EasyAbp.ProcessManagement.Processes;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;

namespace EasyAbp.ProcessManagement.ProcessStateHistories;

public class ProcessStateHistory : AggregateRoot<Guid>, IProcessState, IMultiTenant
{
public virtual Guid? TenantId { get; protected set; }

public virtual Guid ProcessId { get; protected set; }

/// <inheritdoc/>
public virtual string StateName { get; protected set; }

/// <inheritdoc/>
public virtual string SubStateName { get; protected set; }

/// <inheritdoc/>
public virtual ProcessStateFlag StateFlag { get; protected set; }

/// <inheritdoc/>
public string StateSummaryText { get; protected set; }

/// <inheritdoc/>
public virtual string StateDetailsText { get; protected set; }

/// <inheritdoc/>
public virtual DateTime StateUpdateTime { get; protected set; }

protected ProcessStateHistory()
{
}

public ProcessStateHistory(Guid id, Process process) : base(id)
{
TenantId = process.TenantId;

ProcessId = process.Id;

StateUpdateTime = process.StateUpdateTime;
StateName = process.StateName;
SubStateName = process.SubStateName;
StateFlag = process.StateFlag;
StateSummaryText = process.StateSummaryText;
StateDetailsText = process.StateDetailsText;
}
}
Loading