Ejemplo n.º 1
0
        public void ProcessMessage(string json, MonitorRuleType ruleType)
        {
            if (_sqsConfiguration == null)
            {
                return;
            }

            var rules     = _monitorRuleRepository.GetAll();
            var typeRules = rules.Where(x => x.SesMessage.ToLower() == ruleType.ToString().ToLower()).ToList();

            if (typeRules.Count == 0)
            {
                return;
            }

            var o = json.TokenizeJson();

            foreach (var rule in typeRules)
            {
                var extracted = o.FindToken(rule.JsonMatcher);
                if (extracted == null)
                {
                    break;
                }

                var isMatch = extracted.ToString().IsMatch(rule.Regex);

                if (isMatch)
                {
                    _sqsNotifier.Notify($"Rule {rule.Name} match", extracted.ToString(), _sqsConfiguration);
                }
            }
        }
        public IActionResult GetAll()
        {
            var rules = _monitorRuleRepository.GetAll();

            return(Ok(rules.Select(item => item.Create()).ToList()));
        }