public static List <JobRule> ParseJobNotificationRules(ParInput pars, JobOutput outp) { List <JobRule> _rules = new List <JobRule>(); object[] _args = pars.GetPar("rule").argValues; string _temp; foreach (object _arg in _args) { _temp = (string)_arg; // parse rule. JobRule _rule = ParseRule(_temp); // then check if there is a outdescriptor matching the name OutputDescriptor _desc = outp.GetOutputDesc(_rule.outDescName); if (_desc == null) { throw new Exception("No OutputDescriptor with the name '" + _rule.outDescName + "' found!"); } // then check if the type is supported if (!_rule.IsOperatorSupported(_desc.dataType)) { throw new Exception("OutputDescriptor-Type is not supported!"); } _rules.Add(_rule); } return(_rules); }
public static JobRule ParseRule(string data) { JobRule _rule = new JobRule(); bool _operatorKnown = false; string[] _buffer; while (true) { _buffer = SplitByOperator(data, "!="); if (_buffer.Length == 2) { _rule.oper = JobRule.Operation.NotEqual; _operatorKnown = true; break; } _buffer = SplitByOperator(data, "="); if (_buffer.Length == 2) { _rule.oper = JobRule.Operation.Equal; _operatorKnown = true; break; } _buffer = SplitByOperator(data, "<"); if (_buffer.Length == 2) { _rule.oper = JobRule.Operation.Smaller; _operatorKnown = true; break; } _buffer = SplitByOperator(data, ">"); if (_buffer.Length == 2) { _rule.oper = JobRule.Operation.Bigger; _operatorKnown = true; break; } break; } if (_buffer.Length == 2) { _rule.outDescName = _buffer[0]; _rule.compareValue = _buffer[1]; } if (_operatorKnown == false) { throw new Exception("Operation not known!"); } return(_rule); }