public AcceptanceTaskItem StartTask() { AcceptanceTaskItem rc = null; if (_Queue.Tasks.Count > 0) { if (!IsTaskRunning) { if (IsTaskQueued) { rc = QueuedTasks[0]; foreach (AcceptanceTaskItem task in QueuedTasks) { if (task.Id < rc.Id) { rc = task; } } } } } if (rc != null) { rc.State = TaskState.Running; } return(rc); }
public AcceptanceTaskItem PushTask(string folder) { AcceptanceTaskItem rc = null; if (!TaskExists(folder)) { rc = new AcceptanceTaskItem(); int id = -1; foreach (AcceptanceTaskItem task in _Tasks) { if (task.Id > id) { id = task.Id; } } id++; rc.Id = id; rc.Folder = Path.GetFullPath(folder); rc.State = TaskState.Queued; _Tasks.Add(rc); } return(rc); }
public AcceptanceTaskItem FailTask() { AcceptanceTaskItem rc = null; if (IsTaskRunning) { rc = RunningTask; rc.State = TaskState.Failed; } return(rc); }
public AcceptanceTaskItem CompleteLastRun() { AcceptanceTaskItem rc = null; if (_Queue.Tasks.Count > 0) { if (IsLastRunning) { rc = LastRunTask; rc.State = TaskState.LastRunComplete; } } return(rc); }
public AcceptanceTaskItem RestartLastRun() { AcceptanceTaskItem rc = null; if (_Queue.Tasks.Count > 0) { if (!IsTaskRunning && IsLastRunAvailable) { if (!IsLastRunning) { rc = LastRunTask; rc.State = TaskState.LastRunPending; } } } return(rc); }
private void InitializeQueue() { if (File.Exists(_Path + Path.DirectorySeparatorChar + FILE)) { _Queue = TaskQueue.LoadFromFile(_Path, FILE); } else { _Queue = TaskQueue.EmptyQueue; AcceptanceTaskItem lastTask = new AcceptanceTaskItem(); lastTask.Folder = LastRunFolder; lastTask.Id = -1; lastTask.State = TaskState.LastRunNever; _Queue.Tasks.Add(lastTask); TaskQueue.SaveToFile(_Path, FILE, _Queue); } }
public AcceptanceTaskItem CompleteTask() { AcceptanceTaskItem rc = null; if (IsTaskRunning) { rc = RunningTask; rc.State = TaskState.Complete; if (Directory.Exists(LastRunFolder)) { Directory.Delete(LastRunFolder, true); } Directory.Move(rc.Folder, LastRunFolder); File.SetAttributes(LastRunFolder + Path.DirectorySeparatorChar + MARKER, FileAttributes.Normal); File.Delete(LastRunFolder + Path.DirectorySeparatorChar + MARKER); LastRunTask.State = TaskState.LastRunComplete; } return(rc); }