コード例 #1
0
        public TeamMetaIteration(
            IterationApiResponseBase iteration,
            IterationCapacityListApiResponse capacities,
            IterationDaysOffApiResponse teamDaysOff)
        {
            if (iteration == null)
            {
                throw new ArgumentNullException(nameof(iteration));
            }
            if (capacities == null)
            {
                throw new ArgumentNullException(nameof(capacities));
            }
            if (teamDaysOff == null)
            {
                throw new ArgumentNullException(nameof(teamDaysOff));
            }

            Id         = iteration.Id;
            Name       = iteration.Name;
            StartDate  = iteration.Attributes?.StartDate;
            FinishDate = iteration.Attributes?.FinishDate;
            Url        = iteration.Url;

            var capacityList    = capacities.Value.Select(x => new Capacity(x)).ToList();
            var teamDaysOffList = teamDaysOff.DaysOff.Select(x => new DayOff(x)).ToList();

            Capacities  = new ReadOnlyCollection <Capacity>(capacityList);
            TeamDaysOff = new ReadOnlyCollection <DayOff>(teamDaysOffList);
        }
コード例 #2
0
        public TeamCapacity(
            IterationApiResponse iteration,
            IEnumerable <IterationDayOff> iterationDaysOff       = null,
            TeamMemberListApiResponse teamMembers                = null,
            IterationCapacityListApiResponse iterationCapacities = null)
        {
            if (iteration == null)
            {
                throw new ArgumentNullException(nameof(iteration));
            }

            var iterationWorkDays = GetIterationWorkDays(iteration).OrderBy(x => x).Distinct().ToList();

            var teamDaysOff = GetTeamDaysOff(iterationDaysOff).OrderBy(x => x).Distinct().ToList();

            var workDays = iterationWorkDays.Except(teamDaysOff).OrderBy(x => x).Distinct().ToList();

            var members = GetMembers(teamMembers?.Value, iterationCapacities?.Value, iterationWorkDays, teamDaysOff)
                          .ToList();

            IterationWorkDays = new ReadOnlyCollection <DateTime>(iterationWorkDays);
            Members           = new ReadOnlyCollection <TeamMemberCapacity>(members);
            TeamDaysOff       = new ReadOnlyCollection <DateTime>(teamDaysOff);
            WorkDays          = new ReadOnlyCollection <DateTime>(workDays);
        }
コード例 #3
0
 public TeamCapacity(
     IterationApiResponse iteration,
     IterationDaysOffApiResponse iterationDaysOff,
     TeamMemberListApiResponse teamMembers = null,
     IterationCapacityListApiResponse iterationCapacities = null)
     : this(iteration, iterationDaysOff?.DaysOff, teamMembers, iterationCapacities)
 {
 }
コード例 #4
0
ファイル: Leaderboard.cs プロジェクト: inputfalken/VstsDash
        public Leaderboard(
            TeamMemberListApiResponse teamMembers,
            IterationApiResponse iteration,
            IterationCapacityListApiResponse capacities,
            IterationDaysOffApiResponse teamDaysOff,
            Iteration workIteration)
        {
            if (teamMembers == null)
            {
                throw new ArgumentNullException(nameof(teamMembers));
            }
            if (iteration == null)
            {
                throw new ArgumentNullException(nameof(iteration));
            }
            if (capacities == null)
            {
                throw new ArgumentNullException(nameof(capacities));
            }
            if (teamDaysOff == null)
            {
                throw new ArgumentNullException(nameof(teamDaysOff));
            }
            if (workIteration == null)
            {
                throw new ArgumentNullException(nameof(workIteration));
            }

            IterationName = iteration.Name;

            var teamMemberList = teamMembers.Value.ToList();

            var teamCapacity = new TeamCapacity(iteration, teamDaysOff, teamMembers, capacities);

            var workItems = GetWorkItems(workIteration);

            var scores = LeaderboardScoresHelper.GetScores(iteration, workItems, teamMemberList);

            var leaderboardTeamMembers = GetPlayers(teamMemberList, teamCapacity, scores);

            Players      = new ReadOnlyCollection <Player>(leaderboardTeamMembers);
            TeamCapacity = teamCapacity;

            UnassignedScore = scores.Where(x => x.Key == Guid.Empty).Select(x => x.Value).FirstOrDefault();

            TotalScoreAssistsSum = Players.Sum(x => x.ScoreAssistsSum);
            TotalScoreGoalsSum   = Players.Sum(x => x.ScoreGoalsSum);
            TotalScorePointsSum  = Players.Sum(x => x.ScorePointsSum);

            TotalHoursTotalCount = Players.Sum(x => x.Capacity.HoursTotalCount);
            TotalWorkDayCount    = Players.Sum(x => x.Capacity.TotalWorkDayCount);
        }
コード例 #5
0
        public Iteration(
            WorkItemListApiResponse workItems,
            IReadOnlyCollection <TeamMemberApiResponse> teamMembers,
            IterationApiResponse iteration,
            IterationCapacityListApiResponse capacities,
            bool isBacklog)
        {
            if (workItems == null)
            {
                throw new ArgumentNullException(nameof(workItems));
            }
            if (teamMembers == null)
            {
                throw new ArgumentNullException(nameof(teamMembers));
            }
            if (iteration == null)
            {
                throw new ArgumentNullException(nameof(iteration));
            }

            IsBacklog = isBacklog;

            IterationId         = iteration.Id;
            IterationName       = iteration.Name;
            IterationPath       = iteration.Path;
            IterationStartDate  = iteration.Attributes?.StartDate;
            IterationFinishDate = iteration.Attributes?.FinishDate;

            IterationDayCount = IterationStartDate != null && IterationFinishDate != null
                ? (IterationFinishDate.Value - IterationStartDate.Value)
                                .TotalDays + 1
                : 0;

            var items =
                workItems.Value.Select(x => new WorkItem(x, teamMembers))
                .OrderBy(x => x.BacklogPriority)
                .ToList();

            foreach (var item in items)
            {
                var parent = item.ParentId > 0 ? items.FirstOrDefault(x => x.Id == item.ParentId) : null;

                if (parent != null)
                {
                    parent.ChildItems.Add(item);
                }
                else
                {
                    Items.Add(item);
                }
            }

            //this.Items = this.Items.Where(x => x.IsTypeProductBacklogItem || x.IsTypeBug || x.IsTypeTask).ToList();

            Items =
                Items.OrderByDescending(x => x.BacklogPriority > 0).ThenBy(x => x.BacklogPriority).ToList();

            Items.ToList().ForEach(x => x.IsTopLevel = true);

            if (capacities != null)
            {
                var groupedCapacities = from capacity in capacities.Value
                                        //from activity in capacity.Activities
                                        //from daysOff in capacity.DaysOff
                                        group capacity by capacity.TeamMember.Id
                                        into g
                                        select new
                {
                    TeamMember = g.Select(x => x.TeamMember).First(),
                    Activities = g.SelectMany(x => x.Activities),
                    DaysOff    = g.SelectMany(x => x.DaysOff)
                };

                Capacities =
                    groupedCapacities.Select(x => new Capacity(x.TeamMember, x.Activities, x.DaysOff))
                    .ToList();
            }
        }