Exemple #1
0
        public static CronJob Parse(ConfigReader.JobArgs jobArgs, Settings settings = null)
        {
            if (jobArgs == null)
            return null;

              var job = new CronJob { Settings = settings != null ? settings.Clone() : new Settings() };

              if (jobArgs.Reboot)
              {
            job.Reboot = true;
            job.Command = jobArgs.Command;
            return job;
              }

              try
              {
            ParseValue(ref job.Minutes, jobArgs.Minute, 0, 59, false);
            ParseValue(ref job.Hours, jobArgs.Hour, 0, 23, false);
            ParseValue(ref job.Days, jobArgs.Day, 1, 31, false);
            ParseValue(ref job.Months, jobArgs.Month, 1, 12, false);
            ParseValue(ref job.Weekdays, jobArgs.Weekday, 0, 6, true);

            job.Command = jobArgs.Command;
            job.RecalcNextExecTime();

            return job;
              }
              catch (Exception e)
              {
            Logger.Error(e.Message);
            return null;
              }
        }
Exemple #2
0
        public void Setup()
        {
            _sender = new MockMailSender();
              Program.MailSender = _sender;

              _job = new CronJob
              {
            Command = "cmd /c help",
            Settings = new Settings
            {
              MailTo = "test@localhost",
              MailFrom = "cronical@localhost",
              MailStdOut = true,
              SmtpHost = "localhost"
            }
              };
        }