Exemplo n.º 1
0
        /// <summary>
        /// Gets the planned hours for ths item at a given planning.
        /// </summary>
        /// <remarks>If there is no hours planned at the planning number, returns the last planning.</remarks>
        /// <param name="planningNumber">The planning number.</param>
        /// <returns>The planned hours</returns>
        public List <PlannedHour> GetPlannedHoursAtPlanning(int planningNumber)
        {
            if (PlannedHours == null || PlannedHours.Count == 0)
            {
                return(null);
            }

            if (planningNumber < 0)
            {
                planningNumber = 0;
            }

            // this is wrong
            //if(planningNumber >= PlanningNumber)
            //    return PlannedHours.Where(p => p.PlanningNumber == PlanningNumber).ToList();

            // gets the last planning minor then planningNumber
            ICollection <PlannedHour> previousPlans = PlannedHours.Where(h => h.PlanningNumber <= planningNumber).ToArray();

            if (previousPlans == null || previousPlans.Count == 0)
            {
                return(null);
            }
            int lastPlan = previousPlans.Max(h => h.PlanningNumber);

            return(PlannedHours.Where(p => p.PlanningNumber == lastPlan).ToList());
        }
Exemplo n.º 2
0
        public List <PlannedHour> GetValidPlannedHours()
        {
            if (PlannedHours == null || PlannedHours.Count == 0)
            {
                return(null);
            }

            // gets the last planning minor then planningNumber
            return(PlannedHours.Where(h =>
                                      h.SprintNumber >= h.PlanningNumber &&
                                      !PlannedHours.Any(h2 => h2 != h && h2.PlanningNumber > h.PlanningNumber && h2.PlanningNumber <= h.SprintNumber)).ToList());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sync the planned hours collection of the item with the roles of the project.
        /// </summary>
        public void SyncPlannedHoursAndRoles(int?sprintNumber)
        {
            if (Project == null)
            {
                throw new System.Exception("Can not change a item sprint that is not linked to a project");
            }

            if (Project.Roles == null)
            {
                throw new System.Exception("Can not change a item sprint that is not linked to project roles");
            }

            if (PlannedHours == null)
            {
                PlannedHours = new List <PlannedHour>();
            }

            int maxItemPlan = Project.CurrentPlanningNumber;

            if (PlannedHours.Count > 0)
            {
                maxItemPlan = PlannedHours.Max(p => p.PlanningNumber);
            }

            foreach (Role r in Project.Roles)
            {
                PlannedHour hour = PlannedHours.SingleOrDefault(h => h.RoleUId == r.RoleUId);
                if (hour == null)
                {
                    PlannedHours.Add(new PlannedHour()
                    {
                        Role           = r,
                        RoleUId        = r.RoleUId,
                        PlanningNumber = maxItemPlan,
                        SprintNumber   = sprintNumber,
                        BacklogItemUId = this.BacklogItemUId,
                        Hours          = 0
                    });
                }
                else
                {
                    hour.Role = r;
                }
            }

            PlannedHour[] deletedHours = PlannedHours.Where(h => !Project.Roles.Any(r => r.RoleUId == h.RoleUId)).ToArray();
            for (int i = deletedHours.Length - 1; i >= 0; i--)
            {
                PlannedHours.Remove(deletedHours[i]);
            }
        }
Exemplo n.º 4
0
        public void Calculate()
        {
            TargetedHours.Calculate();
            PlannedHours.Calculate();
            Percents.BuildPercent(TargetedHours, PlannedHours);

            if (ExistBufferHours)
            {
                CurrentBufferHours = AvailableWorldBufferHours + (SumTargetedHours - SumPlannedHours);
            }
            else
            {
                CurrentBufferHours = 0;
            }
        }
Exemplo n.º 5
0
 public bool HasTheSameHours(BacklogItem item)
 {
     if (item == null)
     {
         return(false);
     }
     if (item.PlannedHours == null && PlannedHours != null)
     {
         return(false);
     }
     if (item.PlannedHours == null && PlannedHours == null)
     {
         return(true);
     }
     return(PlannedHours.All(h => item.PlannedHours.Any(hh => hh.RoleUId == h.RoleUId && h.Hours == hh.Hours)));
 }
Exemplo n.º 6
0
        public void Calculate(int[] inputHours)
        {
            if (inputHours == null || inputHours.Length < 7)
            {
                Debug.Assert(false);
                return;
            }

            for (int i = 0; i < 7; i++)
            {
                PlannedHours[i] = inputHours[i];
            }
            PlannedHours.Calculate();

            Calculate();
        }
Exemplo n.º 7
0
        public void Calculate(IntArrayTP inputHours)
        {
            if (inputHours == null || inputHours.Count != 7)
            {
                Debug.Assert(false);
                return;
            }

            for (int i = 0; i < 7; i++)
            {
                PlannedHours[i] = inputHours[i];
            }

            PlannedHours.Calculate();

            Calculate();
        }