/// <summary> /// Gets the data using an adapter /// </summary> /// <param name="sender">object which instantiated this event</param> /// <param name="e">Arguments passed along with event</param> private void Load(object sender, EventArgs e) { using (TaskSchedulerAdapter adapter = new TaskSchedulerAdapter()) { this.view.ScheduledTasks = adapter.RetrieveScheduledTasks(); } }
/// <summary> /// Deletes a scheduled task using an adapter /// </summary> /// <param name="sender">object which instantiated this event</param> /// <param name="e">Arguments passed along with event</param> /// <exception cref="ApplicationException">Thrown when a task can't be deleted</exception> private void DeleteScheduledTask(object sender, EventArgs e) { bool isSuccessful = false; using (TaskSchedulerAdapter adapter = new TaskSchedulerAdapter()) { isSuccessful = adapter.DeleteTask(this.view.TaskPath); } if (!isSuccessful) { throw new ApplicationException(Constants.TaskDeleteError); } }
/// <summary> /// Adds the Scheduled task /// </summary> /// <param name="sender">Object which raised this event</param> /// <param name="e">Arguments passed along with this event</param> /// <exception cref="NoActionSpeciifedException">Thrown when a task doesn't have at least one action configured</exception> /// <exception cref="ApplicationException">Thrown when a task can't be created or added</exception> private void AddScheduledTask(object sender, EventArgs e) { bool isSuccessful = false; if (this.view.Task.Actions == null || this.view.Task.Actions.Count == 0) { throw new NoActionSpeciifedException(); } using (TaskSchedulerAdapter adapter = new TaskSchedulerAdapter()) { isSuccessful = adapter.CreateTask(this.view.Task); } if (!isSuccessful) { throw new ApplicationException(Constants.TaskCreateError); } }