/// <summary> /// Filters the exectuion date: Foreach interval the day must be today. Then see if the exectuionTime is still less than today, even when the interval has been added. /// </summary> /// <param name="executionDate"></param> /// <returns></returns> private static bool IsUpcomingDate(GTIdentifier task) { if (task.ExecutionDate <= DateTime.Now) { switch (task.Interval.Trim()) { case "Hourly": if (task.ExecutionDate.TimeOfDay <= DateTime.Now.TimeOfDay) { return(true); } return(false); case "Daily": if (task.ExecutionDate.TimeOfDay <= DateTime.Now.TimeOfDay) { return(true); } return(false); case "Weekly": if (task.ExecutionDate.Date < DateTime.Now.Date) { return(true); } else if (task.ExecutionDate.Date == DateTime.Now.Date && task.ExecutionDate.TimeOfDay <= DateTime.Now.TimeOfDay) { return(true); } return(false); case "Monthly": if (task.ExecutionDate.Date < DateTime.Now) { return(true); } else if (task.ExecutionDate.Date == DateTime.Now.Date && task.ExecutionDate.TimeOfDay <= DateTime.Now.TimeOfDay) { return(true); } return(false); case "Yearly": if (task.ExecutionDate.Date < DateTime.Now) { return(true); } else if (task.ExecutionDate.Date == DateTime.Now.Date && task.ExecutionDate.TimeOfDay <= DateTime.Now.TimeOfDay) { return(true); } return(false); default: return(false); } } return(false); }
/// <summary> /// Removes a task from the <see cref="_taskPool"/> /// </summary> /// <param name="taskId"></param> public static void RemoveTask(GTIdentifier taskId) { if (_taskPool == null) { throw new GuardianException($"The guardian has not been launched yet!"); } if (!_taskPool.TryRemove(taskId, out var task)) { throw new GuardianException($"Given task can not be removed from the task-pool."); } }
public ScheduledConfig(DateTime executionDate, object[] param) { Gtid = new GTIdentifier(executionDate, param[1]?.ToString()); Parameters = param; Type = typeof(GuardianTask); }