public SystemTipsScheduler(readsetting x) { foreach (var timedata in x.timelist) { string[] times = timedata.Split(':'); int tclock, tminute; int.TryParse(times[0], out tclock); int.TryParse(times[1], out tminute); Tuple <int, int> temp = Tuple.Create(tclock, tminute); if (ss.Contains(temp)) //这个时间已经激活过了 { //throw (new ArgumentException("666"));//debug saveLOG.perform("重复的时间"); } else { Schedule(() => new ShowTipsMsgJob(1)).ToRunEvery(1).Days().At(tclock, tminute); ss.Add(temp); } } saveLOG.perform("已添加各提醒"); //Schedule a simple job to run at a specific time //Schedule(() => new ShowTipsMsgJob(1)).ToRunEvery(1).Days().At(9, 00); //Schedule(() => new ShowTipsMsgJob(2)).ToRunEvery(1).Days().At(10, 00); //Schedule(() => new ShowTipsMsgJob(3)).ToRunEvery(1).Days().At(11, 00); //Schedule(() => new ShowTipsMsgJob(4)).ToRunEvery(1).Days().At(12, 00); //Schedule(() => new ShowTipsMsgJob(5)).ToRunEvery(1).Days().At(14, 00); //Schedule(() => new ShowTipsMsgJob(6)).ToRunEvery(1).Days().At(15, 00); //Schedule(() => new ShowTipsMsgJob(7)).ToRunEvery(1).Days().At(16, 00); //Schedule(() => new ShowTipsMsgJob(8)).ToRunEvery(1).Days().At(18, 57); }
static void Main() { saveLOG.perform("start main"); System.Threading.Mutex mutex = new System.Threading.Mutex(true, "RemindDrinking", out bool isRuned); if (isRuned) { saveLOG.perform("Running"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //读取设置文件 saveLOG.perform("Reading settings"); readsetting p = new readsetting(); p.ReadSettings(); //注册定时任务 JobManager.Initialize(new SystemTipsScheduler(p)); saveLOG.perform("Jobmanager Initialized"); Application.Run(new MainForm()); } else { MessageBox.Show("Running", "DrinkingReminder", MessageBoxButtons.OK, MessageBoxIcon.Information); } }