public static void UpdateTaskForNotifyEmail(Task task) { var emails = EmailUtils.GetTextBoxEmailsList(); var isToBeNotified = true; var dontRunLongerThan = form.GetDontRunLongerThanValue(); var emailInfo = new EmailInfo(isToBeNotified, emails, dontRunLongerThan); task.EmailInfo = emailInfo; form.Repository.UpdateTask(task); }
public static Task CreateTask() { Task task = new Task { Id = -1, Name = form.TaskName.Text, ExecutablePath = form.TaskExecutablePath.Text, IsRunning = false, ProcessId = -1, Period = TaskPeriodUtils.SetPeriod(), EmailInfo = EmailUtils.SetEmailInfo() }; return(task); }
private static void StartNotificationTimer(Task task) { if (task.EmailInfo == null) { return; } var taskStartingDate = task.Period.StartDate; var dontRunLongerThanValue = MainForm.Form.GetDontRunLongerThanValue(); bool tryToSend = false; System.Threading.Timer timer = null; timer = new System.Threading.Timer((e) => { if (TaskUtils.IsNull(task)) { TimerUtils.DisposeTimer(timer); return; } if (TimeSpanUtils .GetDifference(DateTime.Now, taskStartingDate) > dontRunLongerThanValue) { if (!tryToSend && TaskRunner.IsTaskRunning(task)) { tryToSend = true; EmailUtils.RedirectToSendEmail(task.Name, dontRunLongerThanValue); } TimerUtils.DisposeTimer(timer); } }, null, 0, 3000); var taskTimer = TimerUtils.AddTimer(timer, task.Name, "Notification Timer", 0, 3000); logger.Info($"{taskTimer} is added."); }
public static List <GridTask> PopulateGridTaskList(List <Task> tasks) { List <GridTask> gridTasks = new List <GridTask>(); foreach (var task in tasks) { var gridTask = new GridTask { Name = task.Name, ExecutablePath = task.ExecutablePath, IsRunning = task.IsRunning, StartProperty = task.Period.Property.ToString(), StartDate = task.Period.StartDate, ProcessId = task.ProcessId, EmailAddress = EmailUtils.GetTaskEmails(task), TimeBetween = TaskUtils.GetTaskTimeBetween(task), }; gridTasks.Add(gridTask); } return(gridTasks); }