public override Trigger CreateTrigger() { DailyTrigger dailyTrigger = null; if (DaysInterval != short.MinValue) { dailyTrigger = new DailyTrigger(StartHour, StartMinute, DaysInterval); } else { dailyTrigger = new DailyTrigger(StartHour, StartMinute); } PopulateTrigger(dailyTrigger); return dailyTrigger; }
private void bREG_Click(object sender, EventArgs e) { E.SetError(tbUri,null); if (tbUri.TextLength == 0) { E.SetError(tbUri, "入力してください"); return; } ScheduledTasks st = new ScheduledTasks(); st.DeleteTask(tbTask.Text); Task task = st.CreateTask(tbTask.Text); task.ApplicationName = System.Reflection.Assembly.GetExecutingAssembly().Location; task.Flags = TaskFlags.SystemRequired; task.MaxRunTime = TimeSpan.FromMinutes(30); task.MaxRunTimeLimited = true; task.Parameters = " \"" + tbUri.Text + "\""; task.WorkingDirectory = Application.StartupPath; if (rbH6.Checked) { DailyTrigger t = new DailyTrigger(9, 0); t.DaysInterval = 1; t.DurationMinutes = 24 * 60; t.IntervalMinutes = 6 * 60; task.Triggers.Add(t); } else if (rbD1.Checked) { DailyTrigger t = new DailyTrigger(9, 0); t.DaysInterval = 1; task.Triggers.Add(t); } else if (rbD3.Checked) { DailyTrigger t = new DailyTrigger(9, 0); t.DaysInterval = 3; task.Triggers.Add(t); } task.Save(tbTask.Text); task.DisplayForEdit(); }
public static Task CreateDaily( string TaskName, string Application, string Parameters, string WorkingFolder, TimeSpan beginTime, double HourInterval, int duration = 0) { if ((HourInterval < 0) || (HourInterval > 12)) { return(null); } DailyTrigger t = new DailyTrigger(); t.StartBoundary = DateTime.Today + beginTime; t.DaysInterval = 1; t.Repetition.Interval = TimeSpan.FromHours(HourInterval); t.Repetition.Duration = duration == 0 ? TimeSpan.Zero : TimeSpan.FromDays(duration); return(AddTask(TaskName, Application, Parameters, WorkingFolder, new Trigger[] { t })); }