예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public AcceptanceTaskItem FailTask()
        {
            AcceptanceTaskItem rc = null;

            if (IsTaskRunning)
            {
                rc       = RunningTask;
                rc.State = TaskState.Failed;
            }

            return(rc);
        }
예제 #4
0
        public AcceptanceTaskItem CompleteLastRun()
        {
            AcceptanceTaskItem rc = null;

            if (_Queue.Tasks.Count > 0)
            {
                if (IsLastRunning)
                {
                    rc       = LastRunTask;
                    rc.State = TaskState.LastRunComplete;
                }
            }

            return(rc);
        }
예제 #5
0
        public AcceptanceTaskItem RestartLastRun()
        {
            AcceptanceTaskItem rc = null;

            if (_Queue.Tasks.Count > 0)
            {
                if (!IsTaskRunning && IsLastRunAvailable)
                {
                    if (!IsLastRunning)
                    {
                        rc       = LastRunTask;
                        rc.State = TaskState.LastRunPending;
                    }
                }
            }

            return(rc);
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
        }