Пример #1
0
        private void BurndownConfig(ReportHelper.ReportConfig config, ScrumFactory.Project project)
        {
            var leftHoursByDay = backlogService.GetBurndownHoursByDay(project.ProjectUId, project.Baseline.ToString());

            if (leftHoursByDay == null)
            {
                return;
            }

            var burndownVM = new BurnDownViewModel();

            burndownVM.ActualHours      = leftHoursByDay.Where(h => h.LeftHoursMetric == LeftHoursMetrics.LEFT_HOURS).ToArray();
            burndownVM.ActualHoursAhead = leftHoursByDay.Where(h => h.LeftHoursMetric == LeftHoursMetrics.LEFT_HOURS_AHEAD).ToArray();
            burndownVM.PlannedHours     = leftHoursByDay.Where(h => h.LeftHoursMetric == LeftHoursMetrics.PLANNING).ToArray();

            config.ReportViewModels.Add("burndown", burndownVM);
        }
        public int InsertProject(ScrumFactory.Project project)
        {
            using (var context = new ScrumFactoryEntities(this.connectionString)) {
                context.Projects.AddObject(project);

                if (project.Memberships != null)
                {
                    foreach (ProjectMembership m in project.Memberships)
                    {
                        context.AddObject("ProjectMemberships", m);
                    }
                }

                context.SaveChanges();
            }

            return(project.ProjectNumber);
        }
        public void UpdateProject(ScrumFactory.Project project)
        {
            using (var context = new ScrumFactoryEntities(this.connectionString)) {
                var projectOld = GetProject(project.ProjectUId);
                context.AttachTo("Projects", projectOld);
                context.ApplyCurrentValues <Project>("Projects", project);

                if (projectOld.Memberships == null)
                {
                    projectOld.Memberships = new List <ProjectMembership>();
                }

                if (project.Memberships == null)
                {
                    project.Memberships = new List <ProjectMembership>();
                }

                var insertedMemberships = project.Memberships.Where(m => !projectOld.Memberships.Any(o => (o.MemberUId == m.MemberUId && o.RoleUId == m.RoleUId))).ToList();
                var updatedMemberships  = project.Memberships.Where(m => projectOld.Memberships.Any(o => (o.MemberUId == m.MemberUId && o.RoleUId == m.RoleUId))).ToList();
                var deletedMemberships  = projectOld.Memberships.Where(m => !project.Memberships.Any(o => (o.MemberUId == m.MemberUId && o.RoleUId == m.RoleUId))).ToList();

                foreach (ProjectMembership m in insertedMemberships)
                {
                    context.AddObject("ProjectMemberships", m);
                }
                foreach (ProjectMembership m in updatedMemberships)
                {
                    context.ApplyCurrentValues <ProjectMembership>("ProjectMemberships", m);
                }
                foreach (ProjectMembership m in deletedMemberships)
                {
                    context.DeleteObject(m);
                }


                context.SaveChanges();
            }
        }
Пример #4
0
        private ReportHelper.ReportConfig CreateReportConfig(ScrumFactory.Project project, string group, string template, string name)
        {
            var config = new ReportHelper.ReportConfig(group, template, name);

            // add project
            project.Sprints = project.Sprints.OrderBy(s => s.SprintNumber).ToList();
            config.ReportObjects.Add(project);

            // get project members
            var members = teamService.GetProjectMembers(project.ProjectUId);

            foreach (var mm in project.Memberships)
            {
                mm.Member = members.SingleOrDefault(m => m.MemberUId == mm.MemberUId);
            }

            // add risks
            ICollection <Risk> risks = projectService.GetProjectRisks(project.ProjectUId);

            config.ReportObjects.Add(risks);

            // add groups
            ICollection <BacklogItemGroup> groups = backlogService.GetBacklogItemGroups(project.ProjectUId);

            config.ReportObjects.Add(groups);

            // add itens
            ICollection <BacklogItem> items = backlogService.GetBacklog(project.ProjectUId, null, (short)ScrumFactory.Services.BacklogFiltersMode.ALL);

            foreach (BacklogItem item in items)
            {
                item.ValidPlannedHours = item.GetValidPlannedHours();

                if (item.ValidPlannedHours == null)
                {
                    item.FirstSprintWorked = 1;
                    item.LastSprintWorked  = 1;
                    item.OrderSprintWorked = 1;
                }
                else
                {
                    int?firstSprint = item.ValidPlannedHours.Min(h => h.SprintNumber);
                    item.FirstSprintWorked = firstSprint.HasValue ? firstSprint.Value : project.LastSprint.SprintNumber;

                    int?lastSprint = item.ValidPlannedHours.Max(h => h.SprintNumber);
                    item.LastSprintWorked = lastSprint.HasValue ? lastSprint.Value : project.LastSprint.SprintNumber;

                    if (item.FirstSprintWorked < project.CurrentValidSprint.SprintNumber)
                    {
                        item.OrderSprintWorked = item.LastSprintWorked;
                    }
                    else
                    {
                        item.OrderSprintWorked = item.FirstSprintWorked;
                    }
                }

                item.Group = groups.SingleOrDefault(g => g.GroupUId == item.GroupUId);
            }

            config.ReportObjects.Add(items);


            // add constraints
            ICollection <ProjectConstraint> constraints = constraintsService.GetProjectConstraints(project.ProjectUId);

            config.ReportObjects.Add(constraints);

            // add end date
            config.AddReportVar("ProjectEndDate", project.LastSprint.EndDate);


            if (project.CurrentSprint != null)
            {
                if (group != "SprintReview")
                {
                    config.ReportVars.Add("ProjectCurrentSprintNumber", project.CurrentSprint.SprintNumber.ToString());
                }
                else
                {
                    // sets the current sprint
                    // if its at the end of the sprint, consider the next sprint as current
                    var currentSprint = project.CurrentSprint.SprintNumber;
                    if (project.CurrentSprint.DaysLeft <= 4)
                    {
                        currentSprint++;
                    }
                    if (currentSprint > project.LastSprint.SprintNumber)
                    {
                        currentSprint = project.LastSprint.SprintNumber;
                    }

                    // sets the previous sprint
                    var previousSprint = currentSprint - 1;
                    if (previousSprint < 1)
                    {
                        previousSprint = 1;
                    }
                    config.ReportVars.Add("ProjectCurrentSprintNumber", currentSprint.ToString());
                    config.ReportVars.Add("ProjectPreviousSprintNumber", previousSprint.ToString());

                    //if (project.CurrentSprint.SprintNumber > 1)
                    //{
                    //    config.ReportVars.Add("ProjectCurrentSprintNumber", project.CurrentSprint.SprintNumber.ToString());
                    //    config.ReportVars.Add("ProjectPreviousSprintNumber", (project.CurrentSprint.SprintNumber - 1).ToString());
                    //}
                    //else
                    //{
                    //    if (project.Sprints.Count > project.CurrentSprint.SprintNumber + 1)
                    //        config.ReportVars.Add("ProjectCurrentSprintNumber", (project.CurrentSprint.SprintNumber + 1).ToString());
                    //    else
                    //        config.ReportVars.Add("ProjectCurrentSprintNumber", project.CurrentSprint.SprintNumber.ToString());

                    //    config.ReportVars.Add("ProjectPreviousSprintNumber", project.CurrentSprint.SprintNumber.ToString());
                    //}
                }
            }

            return(config);
        }