Ejemplo n.º 1
0
        public static IEnumerable <Tasks> GetAllChildTasks(this Tasks task)
        {
            TreeGridModel model = new TreeGridModel();

            model.GetChildren(task, new Repository <Tasks>().GetCollections().ToList());
            return(model.ChildTasks);
        }
Ejemplo n.º 2
0
        public IEnumerable <Tasks> ShowSortedTasks(Guid?ProjectGUID)
        {
            var           tasks    = base.dbset.OrderBy(t => t.TaskID).Where(t => t.ProjectGUID == ProjectGUID).ToList();
            TreeGridModel treeGrid = new TreeGridModel(tasks);

            return(treeGrid.SortedTasks);
        }
Ejemplo n.º 3
0
        public static IEnumerable <int> GetRootTasksWorkTimeSum(this IEnumerable <Tasks> rootTasks, IEnumerable <Tasks> tasksFromRepo)
        {
            List <int>    rootTasksWorkTimeSum = new List <int>();
            TreeGridModel treeGrid             = new TreeGridModel(tasksFromRepo.ToList());

            foreach (var root in rootTasks)
            {
                treeGrid.ChildLeafTasks = new List <Tasks>();
                treeGrid.GetChildLeafTasks(root);
                int _sum = (int)treeGrid.ChildLeafTasks.ToList().Select(t => t.EstWorkTime).Sum();
                rootTasksWorkTimeSum.Add(_sum);
            }
            return(rootTasksWorkTimeSum);
        }
Ejemplo n.º 4
0
        public static IEnumerable <int> GetRootTasksCompletedRate(this IEnumerable <Tasks> rootTasks, IEnumerable <Tasks> tasksFromRepo)
        {
            List <int>    rootTasksCompletedRate = new List <int>();
            TreeGridModel treeGrid = new TreeGridModel(tasksFromRepo.ToList());

            foreach (var root in rootTasks)
            {
                treeGrid.ChildLeafTasks = new List <Tasks>();
                treeGrid.GetChildLeafTasks(root);
                int completedLeafTaskCount = 0;
                int totalLeafCount         = treeGrid.ChildLeafTasks.Count();
                foreach (var leaf in treeGrid.ChildLeafTasks)
                {
                    string      status      = (leaf.TaskStatusID ?? default(int)).ToString();
                    Task_Status leaf_Status = (Task_Status)Enum.Parse(typeof(Task_Status), status);
                    if (leaf_Status == Task_Status.Completed)
                    {
                        completedLeafTaskCount++;
                    }
                }
                int rate = 0;
                if (totalLeafCount == 0)
                {
                    string      status      = (root.TaskStatusID ?? default(int)).ToString();
                    Task_Status root_Status = (Task_Status)Enum.Parse(typeof(Task_Status), status);
                    if (root_Status == Task_Status.Completed)
                    {
                        rate = 100;
                    }
                }
                else
                {
                    rate = completedLeafTaskCount * 100 / totalLeafCount;
                }

                rootTasksCompletedRate.Add(rate);
            }

            return(rootTasksCompletedRate);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 回傳帶有orderID、parentOrderID排序完成的List&lt;Task>
        /// </summary>
        /// <param name="tasks"></param>
        /// <returns></returns>
        public static IEnumerable <Tasks> GetSortedTasks(this IEnumerable <Tasks> tasks)
        {
            TreeGridModel treeGrid = new TreeGridModel(tasks.ToList());

            return(treeGrid.SortedTasks);
        }