/// <summary> /// Process that returns the port after adding a list of scenario Id's /// that have a url rule that matches the request path. /// </summary> /// <param name="port">The port containing necessary data</param> /// <returns>Port containing processed data</returns> public override T Process(T port) { if (!IsPipelineValid(ref port, GetType())) { return(port); } foreach (var scenario in port.Scenarios) { foreach (var rule in scenario.RequestMatchRules.UrlRules) { var assertsList = assertFactory.CreateAssert(rule, port.Path); if (!assertsList.Any()) { port.URLMatchResults.Add(new MatchResult(MatchResultType.Ignore, scenario.Id, scenario.defaultScenario)); } else { port.URLMatchResults.Add(ruleMatcher.Match(assertsList.ToArray()) ? new MatchResult(MatchResultType.Success, scenario.Id, scenario.defaultScenario) : new MatchResult(MatchResultType.Fail, scenario.Id, scenario.defaultScenario)); } } } return(port); }
public bool Process(PushEventPayload payload) { try { var rule = _ruleMatcher.Match(payload.Ref, payload.Repository?.Url); if (rule != null) { _processExecutor.Execute(rule.Execute); return(true); } } catch (Exception ex) { _log.LogError(ex, "Unexpected error while trying to execute script"); return(false); } return(false); }
public async Task <EventProcessorResult> Process(Guid eventLog, PushEventPayload payload, CancellationToken token) { try { var rule = _ruleMatcher.Match(payload.Ref, payload.Repository?.Url); if (rule != null) { await _executionRequestRepository.Create(rule, eventLog, token); return(new EventProcessorResult(true, $"{rule.Name} rule matched", rule)); } } catch (Exception ex) { _log.LogError(ex, "Unexpected error while trying to execute script"); return(new EventProcessorResult(false, $"Unexpected error while trying to process event: {ex.Message}")); } return(new EventProcessorResult(false, "No matching rule")); }