Example #1
0
        public JobNotificationSettings ParseJobNotificationSettings(ParInput pars)
        {
            JobNotificationSettings _settings = new JobNotificationSettings();

            string[] _temp = pars.GetPar(NOTI_SMTP_ENDPOINT).argValues[0].ToString().Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
            if (_temp.Length == 2)
            {
                _settings.login.smtpAddr = _temp[0];

                try
                {
                    _settings.login.port = Int32.Parse(_temp[1]);
                }
                catch (Exception)
                {
                    throw new Exception(CLIError.Error(CLIError.ErrorType.ArgumentTypeError, "Could not parse SMTP-Port!", true));
                }
            }
            else
            {
                throw new Exception(CLIError.Error(CLIError.ErrorType.SyntaxError, "SMTP-Endpoint could not be parsed correctly!", true));
            }

            string[] _temp2 = pars.GetPar(NOTI_SMTP_LOGIN).argValues[0].ToString().Split(new string[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
            if (_temp2.Length == 2)
            {
                try
                {
                    _settings.login.mail = new MailAddress(_temp2[0]);
                }
                catch (Exception)
                {
                    throw new Exception(CLIError.Error(CLIError.ErrorType.ArgumentTypeError, "Could not parse MailAddress!", true));
                }

                _settings.login.password = _temp2[1];
            }
            else
            {
                throw new Exception(CLIError.Error(CLIError.ErrorType.SyntaxError, "SMTP-Login could not be parsed correctly!", true));
            }

            _settings.mailAddr = new MailAddress[1] {
                (MailAddress)pars.GetPar(NOTI_SMTP_MAILS).argValues[0]
            };

            return(_settings);
        }
Example #2
0
        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);
        }