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; } }
public static ServiceJob Parse(ConfigReader.JobArgs jobArgs, Settings settings = null) { if (jobArgs == null) return null; return new ServiceJob { Settings = settings != null ? settings.Clone() : new Settings(), Command = jobArgs.Command }; }
public void TestClone() { var env = new Settings { Home = "home", MailTo = "to-email", MailFrom = "from-email", SmtpHost = "server", SmtpPass = "******", SmtpUser = "******" }; var env2 = env.Clone(); Assert.AreNotSame(env, env2); Assert.AreEqual(env.Home, env2.Home); Assert.AreEqual(env.MailFrom, env2.MailFrom); Assert.AreEqual(env.MailTo, env2.MailTo); Assert.AreEqual(env.SmtpHost, env2.SmtpHost); Assert.AreEqual(env.SmtpPass, env2.SmtpPass); Assert.AreEqual(env.SmtpUser, env2.SmtpUser); }