Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <param name="NewStart"></param>
        /// <returns></returns>
        public bool SetTaskEnd(ProjectTask ATask, DateTime NewEnd)
        {
            if (_Tasks.Contains(ATask) && ATask.End != NewEnd)
            {
                ATask.End = NewEnd;

                NotifyTaskChange(ATask, ProjectEventArgs.ProjectEventType.TaskChanged);

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <returns></returns>
        public bool SetTaskFixed(ProjectTask ATask, bool SetFixed)
        {
            if (_Tasks.Contains(ATask))
            {
                ATask.Fixed = SetFixed;

                NotifyTaskChange(ATask, ProjectEventArgs.ProjectEventType.TaskChanged);

                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <param name="NewStart"></param>
        /// <returns></returns>
        public bool SetTaskStart(ProjectTask ATask, DateTime NewStart)
        {
            if (_Tasks.Contains(ATask) && ATask.Start != NewStart)
            {
                ATask.Start = NewStart;

                NotifyTaskChange(ATask, ProjectEventArgs.ProjectEventType.TaskChanged);

                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <TaskNode> GetTaskHierarchy()
        {
            List <TaskNode> Nodes = new List <TaskNode>();

            for (int Index = 0; Index < _Tasks.Count; Index++)
            {
                ProjectTask SomeTask = _Tasks[Index];

                if (SomeTask.Level == 0)
                {
                    Nodes.Add(new TaskNode(this, SomeTask, null));
                }
            }

            return(Nodes);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <returns></returns>
        public TaskNode FindTaskNodeForTask(List <TaskNode> Nodes, ProjectTask ATask)
        {
            TaskNode Value = null;

            foreach (TaskNode ANode in Nodes)
            {
                Value = ANode.FindNodeForTask(ATask);

                if (Value != null)
                {
                    break;
                }
            }

            return(Value);
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="NewTask"></param>
        public TaskNode(Project AProject, ProjectTask ATask, TaskNode AParent)
        {
            _Task     = ATask;
            _Parent   = AParent;
            _Children = new List <TaskNode>();

            List <ProjectTask> SomeChildren = AProject.GetChildTasks(ATask);

            foreach (ProjectTask AChild in SomeChildren)
            {
                if (AChild.Level == ATask.Level + 1)
                {
                    _Children.Add(new TaskNode(AProject, AChild, this));
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AnotherTask"></param>
        /// <returns></returns>
        public int QualifyVersus(ProjectTask AnotherTask)
        {
            // Check whether one task depends on the other
            if (_ID != 0 && AnotherTask._ID != 0)
            {
                if (_DependsOnTaskID == AnotherTask._ID)
                {
                    return(-1);
                }
                if (AnotherTask._DependsOnTaskID == _ID)
                {
                    return(1);
                }
            }

            // Compare the tasks' priorities
            if (_Priority > AnotherTask._Priority)
            {
                return(-1);
            }
            if (_Priority < AnotherTask._Priority)
            {
                return(1);
            }

            // Compare the tasks' delivery limit date
            if (_DeliveryLimit < AnotherTask._DeliveryLimit)
            {
                return(-1);
            }
            if (_DeliveryLimit > AnotherTask._DeliveryLimit)
            {
                return(1);
            }

            // Compare the tasks' index
            if (_Index < AnotherTask._Index)
            {
                return(-1);
            }
            if (_Index > AnotherTask._Index)
            {
                return(1);
            }

            return(0);
        }
Exemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <returns></returns>
        public bool MoveTaskRight(ProjectTask ATask)
        {
            if (CanTaskMoveRight(ATask))
            {
                List <ProjectTask> Children = GetChildTasks(ATask);

                ATask.Level++;
                foreach (ProjectTask Child in Children)
                {
                    Child.Level++;
                }

                NotifyTaskChange(ATask, ProjectEventArgs.ProjectEventType.TaskChanged);

                return(true);
            }

            return(false);
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <returns></returns>
        public bool MoveTaskLeft(ProjectTask ATask)
        {
            if (ATask.Level > 0)
            {
                List <ProjectTask> Children = GetChildTasks(ATask);

                ATask.Level--;
                foreach (ProjectTask Child in Children)
                {
                    Child.Level--;
                }

                NotifyTaskChange(ATask, ProjectEventArgs.ProjectEventType.TaskChanged);

                return(true);
            }

            return(false);
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <returns></returns>
        public bool CanTaskMoveRight(ProjectTask ATask)
        {
            for (int Index = 0; Index < _Tasks.Count; Index++)
            {
                if (_Tasks[Index] == ATask)
                {
                    if (Index == 0)
                    {
                        return(false);
                    }

                    if (_Tasks[Index - 1].Level >= ATask.Level)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <returns></returns>
        public String GetWBSForTask(ProjectTask ATask)
        {
            String Value = String.Empty;

            List <TaskNode> Nodes = GetTaskHierarchy();
            TaskNode        ANode = FindTaskNodeForTask(Nodes, ATask);

            while (ANode != null)
            {
                if (Value.Length > 0)
                {
                    Value = "." + Value;
                }
                Value = (ANode.Task.Index + 1).ToString() + Value;

                ANode = ANode.Parent;
            }

            return(Value);
        }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        public bool AddTaskAfter(Workspace AWorkspace, ProjectTask ATask)
        {
            for (int Index = 0; Index < _Tasks.Count; Index++)
            {
                if (_Tasks[Index] == ATask)
                {
                    ProjectTask ANewTask = new ProjectTask();

                    ANewTask.ID    = AWorkspace.GenerateTaskID();
                    ANewTask.Level = _Tasks[Index].Level;

                    _Tasks.Insert(Index + 1, ANewTask);

                    NotifyTaskChange(ANewTask, ProjectEventArgs.ProjectEventType.TaskAdded);

                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <returns></returns>
        public TaskNode FindNodeForTask(ProjectTask ATask)
        {
            TaskNode Value = null;

            if (_Task == ATask)
            {
                return(this);
            }

            foreach (TaskNode ANode in _Children)
            {
                Value = ANode.FindNodeForTask(ATask);

                if (Value != null)
                {
                    break;
                }
            }

            return(Value);
        }
Exemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="AWorkspace"></param>
        /// <returns></returns>
        public bool DependenciesFinished(Project AProject)
        {
            // Is there any valid ID for a dependency?
            if (_DependsOnTaskID == 0)
            {
                // No, so return true
                return(true);
            }

            // Find the task that this task depends on
            ProjectTask TheTask = AProject.GetTaskByID(_DependsOnTaskID);

            // Does it exist?
            if (TheTask != null)
            {
                // Yes, so return whether this task is finished
                return(TheTask.Finished);
            }

            // In any other case, return true
            return(true);
        }
Exemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="SomeTasks"></param>
 /// <param name="ATask"></param>
 public void AggregateNonEffectiveTasks(Project AProject, List <ProjectTask> SomeTasks, ProjectTask ATask)
 {
     if (AProject.TaskHasChildren(ATask) == true)
     {
         SomeTasks.Add(ATask);
     }
 }
Exemplo n.º 16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ATask"></param>
 /// <returns></returns>
 public bool TaskHasChildren(ProjectTask ATask)
 {
     // Just return whether the task's children count exceeds 0
     return(GetChildTasks(ATask).Count > 0);
 }
Exemplo n.º 17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ANewProject"></param>
 public ProjectEventArgs(Project NewProject, ProjectTask NewTask, ProjectEventType NewType)
 {
     _Project = NewProject;
     _Task    = NewTask;
     _Type    = NewType;
 }
Exemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ATask"></param>
        /// <param name="CurrentTime"></param>
        /// <returns></returns>
        public List <Worker> GetWorkersForTask(ProjectTask ATask, DateTime CurrentTime)
        {
            List <Worker> WorkerList = new List <Worker>();

            if (ATask.AssignedWorker != String.Empty)
            {
                foreach (Worker TheWorker in _Workers)
                {
                    if (TheWorker.Trigram == ATask.AssignedWorker)
                    {
                        if (TheWorker.IsAvailableAt(CurrentTime))
                        {
                            if (WorkerList.Contains(TheWorker) == false)
                            {
                                WorkerList.Add(TheWorker);
                            }
                        }
                    }
                }
            }

            foreach (Worker TheWorker in _Workers)
            {
                if (TheWorker.IsAvailableAt(CurrentTime))
                {
                    if (TheWorker.KnowsModule(ATask.ModuleName))
                    {
                        if (WorkerList.Contains(TheWorker) == false)
                        {
                            WorkerList.Add(TheWorker);
                        }
                    }
                }
            }

            try
            {
                WorkerList.Sort(
                    delegate(Worker a, Worker b)
                {
                    if (a.Trigram == ATask.AssignedWorker)
                    {
                        return(-1);
                    }
                    if (b.Trigram == ATask.AssignedWorker)
                    {
                        return(1);
                    }

                    if (a.PercentageKnowledgeForModule(ATask.ModuleName) > b.PercentageKnowledgeForModule(ATask.ModuleName))
                    {
                        return(-1);
                    }
                    if (a.PercentageKnowledgeForModule(ATask.ModuleName) < b.PercentageKnowledgeForModule(ATask.ModuleName))
                    {
                        return(1);
                    }

                    return(0);
                }
                    );
            }
            catch
            {
            }

            return(WorkerList);
        }