Esempio n. 1
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);
        }
Esempio n. 2
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);
        }