void timer_Tick(object sender, EventArgs e) { bool isRunning = ScheduleJobSpawner.IsJobRunning(job); if (isRunning) { wasRunning = true; } else if (wasRunning) { wasRunning = true; job.ReFresh(); lblLastStarted.Text = job.LastStarted.HasValue ? job.LastStarted.Value.ToString("yyyy:MM:dd HH:mm:ss") : "Never"; lblLastFinished.Text = job.LastFinished.HasValue ? job.LastFinished.Value.ToString("yyyy:MM:dd HH:mm:ss") : "Never"; lblNextStart.Text = ""; if (job.Logs.Count > 0) { ScheduleJobLog log = job.Logs[0]; textBox1.Text = log.Entry; textBox1.ForeColor = !log.Success ? Color.Red : SystemColors.WindowText; textBox1.Select(0, 0); } } UpdateNext(); btnRunJob.Enabled = !isRunning; btnEdit.Enabled = !isRunning; btnDelete.Enabled = !isRunning; lblLastResult.Visible = !isRunning; lblIsRunning.Visible = isRunning; btnViewLog.Enabled = job.Logs.Count > 0; }
private void btnRunJob_Click(object sender, EventArgs e) { ScheduleJobSpawner.SpawAndRun(job); timer_Tick(timer, new EventArgs()); //Enabled = false; //try { // job.Execute(); // Form1.Instance.RefreshJobs(); //} finally { // Enabled = true; //} }
public void Execute(JobExecutionContext context) { int jobID; if (!int.TryParse(context.JobDetail.Name, out jobID)) { Logger.Log("Error getting ID for job to execute", LogStatuses.Error); return; } BackupScheduleWrapper schedule = Configuration.GetSchedule(jobID); if (schedule == null) { Logger.Log("Error getting Schedule for {0}".FillBlanks(jobID), LogStatuses.Error); return; } Logger.Log("Running schedule {0}".FillBlanks(schedule.Name), LogStatuses.Execute); ScheduleJobSpawner.SpawAndRun(schedule); }