-
Notifications
You must be signed in to change notification settings - Fork 10
1. Processes
Marjan Nikolovski edited this page Apr 9, 2021
·
3 revisions
The processes are the core of Signals. Out of the box Signals supports Business processes, API processes, Distributed processes, and Recurring processes.
- Critical
- SignalsAuthorizeProcess
- ApiProcess
Each process has a context that can be accessed.
ILogger Logger;
IAuditProvider AuditProvider;
IAuthenticationManager Authentication;
IAuthorizationManager Authorization;
IStorageProvider Storage;
ICache Cache;
IPermissionManager PermissionManager;
ILocalizationProvider LocalizationProvider;
Mediator Mediator;
IBenchmarker InternalBenchmarker;
ProcessBenchmarker Benchmarker;
ClaimsPrincipal CurrentUserPrincipal;
- Authentication
- Authorization
- Error logging
- Auditing
- Error managing
- Critical process notifying
- Execution
For recurring processes and distributed execution in the work method Authentication and Authorization are disabled.
/// Business process context
/// </summary>
public interface IMyProcessContext : IBaseProcessContext
{
}
/// <summary>
/// Business process context
/// </summary>
[Export(typeof(IMyProcessContext))]
public class MyProcessContext : BaseProcessContext, IMyProcessContext
{
}
public abstract class MyProcess<TResponse> : BaseProcess<TResponse>,
IBusinessProcess
where TResponse : VoidResult, new()
{
/// <summary>
/// Business process context
/// </summary>
[Import]
protected virtual IMyProcessContext Context
{
get => _context;
set { (value as MyProcessContext).SetProcess(this); _context = value; }
}
private IMyProcessContext _context;
/// <summary>
/// Base process context upcasted from Business process context
/// </summary>
internal override IBaseProcessContext BaseContext => Context;
/// <summary>
/// Authentication and authorization layer
/// </summary>
/// <returns></returns>
public abstract TResponse Auth();
/// <summary>
/// Validation layer
/// </summary>
/// <returns></returns>
public abstract TResponse Validate();
/// <summary>
/// Execution layer
/// </summary>
/// <returns></returns>
public abstract TResponse Handle();
/// <summary>
/// Execution using base strategy
/// </summary>
/// <returns></returns>
internal virtual TResponse Execute()
{
var result = Auth();
if (result.IsFaulted) return result;
result = Validate();
if (result.IsFaulted) return result;
result = Handle();
return result;
}
/// <summary>
/// Entry point executed by the factory
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
internal override TResponse ExecuteProcess(params object[] args)
{
return Execute();
}
}