public async Task <NotifactionPipelineExecutionResults> Execute(NotifcationTrigger trigger) { _logger.LogDebug("start of {name} pipeline", Name); if (TriggerIdentifier != trigger.GetTypeIdentifier()) { _logger.LogDebug("type mismatch. Expected a trigger of {type} but received {otherType}", TriggerIdentifier, trigger.GetTypeIdentifier()); return(NotifactionPipelineExecutionResults.TriggerNotMatch); } if (Condition != NotificationCondition.True) { if (await Condition.IsValid(trigger) == false) { _logger.LogDebug("the trigger doens't satisfy the condition. Execution of pipeline stopped"); return(NotifactionPipelineExecutionResults.ConditionNotMatched); } else { _logger.LogDebug("the trigger {trgger} meet the condtion {condition}", trigger, Condition); } } else { _logger.LogDebug("no conditions applied. actor enabled"); } _logger.LogDebug("executing actor..."); try { Boolean actorResult = await Actor.Handle(trigger); if (actorResult == false) { _logger.LogError("Actor {actor} of pipeline {name} failed.", Actor, Name); return(NotifactionPipelineExecutionResults.ActorFailed); } return(NotifactionPipelineExecutionResults.Success); } catch (Exception ex) { _logger.LogError("unable to execute actor", ex.ToString()); return(NotifactionPipelineExecutionResults.ActorFailed); } }
internal protected abstract Task <Boolean> Handle(NotifcationTrigger trigger);
public abstract Task<Boolean> IsValid(NotifcationTrigger trigger);
public bool CanExecute(NotifcationTrigger trigger) => trigger.GetTypeIdentifier() == TriggerIdentifier;
public override Task<Boolean> IsValid(NotifcationTrigger trigger) => Task.FromResult(true);