Exemple #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);
        }
Exemple #2
0
        public override string Execute(int consoleWidth)
        {
            JobNotificationSettings _settings = ParseJobNotificationSettings(pars);

            return("<color><red>Default mail-settings set.");
        }