예제 #1
0
        /// <summary>
        /// Creates the report for all teams.
        /// </summary>
        /// <param name="teams">The teams.</param>
        /// <param name="triageTeams">The triage teams.</param>
        /// <param name="recipients">The recipients.</param>
        /// <returns></returns>
        public async Task CreateReportForAllTeams(List <TeamModel> teams, List <TeamModel> triageTeams, List <RecipientModel> recipients)
        {
            var impededItems = new List <ImpedimentItemModel>();
            var statusItems  = new List <StatusItemModel>();
            var triageItems  = new List <TriageItemModel>();

            var tasks = teams.Select(async team =>
            {
                var activeSprintIssuesModel = await _activeSpintIssuesService.GetActiveSpintIssuesModel(team);

                var teamImpededItems =
                    _tableItemsService.GetImpedimentsList(activeSprintIssuesModel.ImpedimentIssues, team.TeamName);
                lock (impededItems)
                {
                    impededItems.AddRange(teamImpededItems);
                }

                var teamStatusItems = await _tableItemsService.GetStatusItemsList(activeSprintIssuesModel.NotImpedimentIssues, team);

                lock (statusItems)
                {
                    statusItems.AddRange(teamStatusItems);
                }
            });

            await Task.WhenAll(tasks);

            var triageTasks = triageTeams.Select(async team =>
            {
                var teamTriageItems = await _triageService.GetTriageItemsList(team);
                lock (triageItems)
                {
                    triageItems.AddRange(teamTriageItems);
                }
            });

            await Task.WhenAll(triageTasks);

            _emailSenderService.FormationTablesForLetter(impededItems, statusItems, recipients, triageItems);
        }