private void InitialiseWorkItemDtos(SprintProgressDto sprintProgressDto)
 {
     if (sprintProgressDto.WorkItemDtos == null)
     {
         sprintProgressDto.WorkItemDtos = new List <WorkItemDto>();
     }
 }
Beispiel #2
0
        public static void Save(SprintProgress progress)
        {
            var sql = new Sql("SELECT sprintId, dateTime, jsonData FROM dSprintProgress WHERE sprintId=@sprintId AND dateTime=@dateTime", new { sprintId = progress.SprintId, dateTime = progress.DateTime });
            var dto = Database.Fetch <SprintProgressDto>(sql).FirstOrDefault();

            if (dto == null)
            {
                dto = new SprintProgressDto
                {
                    SprintId = progress.SprintId,
                    DateTime = progress.DateTime,
                    JsonData = JsonConvert.SerializeObject(new JsonData {
                        Points = progress.Points, Unscheduled = progress.Unscheduled
                    })
                };
                Database.Insert(dto);
            }
            else
            {
                dto.JsonData = JsonConvert.SerializeObject(new JsonData {
                    Points = progress.Points, Unscheduled = progress.Unscheduled
                });
                Database.Update(dto);
            }
        }
        private async Task PopulateSprintProgressDto(SprintProgressDto sprintProgressDto, EffortType effortType, DateTime sprintDateWithTime, string sprintDateYMDTHMSMSZ, List <Workitem> workItemsInSprintOnSprintDate)
        {
            if (workItemsInSprintOnSprintDate == null || workItemsInSprintOnSprintDate.Count == 0)
            {
                //handle zero work items on day zero/one of the sprint (or on dates in the future) as the first (aka "zeroth") day of sprint seems to return zero work items e.g. if sprint starts on 10th Jan
                var workItemDto = new WorkItemDto
                {
                    AsOf = sprintDateWithTime
                };

                InitialiseWorkItemDtos(sprintProgressDto);

                sprintProgressDto.WorkItemDtos.Add(workItemDto);
            }
            else
            {
                var valueBs = await GetValueBsFromWorkitems(sprintDateYMDTHMSMSZ, workItemsInSprintOnSprintDate);

                InitialiseWorkItemDtos(sprintProgressDto);

                foreach (var valueB in valueBs)
                {
                    var workItemDto = GetWorkItemDto(effortType, sprintDateWithTime, valueB);
                    sprintProgressDto.WorkItemDtos.Add(workItemDto);
                }
            }
        }
        public SprintProgressDto GetSprintProgressDto(string teamSettingsIterationsJson)
        {
            var sprintIteration = JsonConvertGetSprintIteration(teamSettingsIterationsJson);

            var sprintProgressDto = new SprintProgressDto
            {
                IterationNumber = sprintIteration.IterationNumber,
                SprintEnd       = sprintIteration.SprintEnd.HasValue ? sprintIteration.SprintEnd.Value : DateTime.MinValue,
                SprintStart     = sprintIteration.SprintStart.HasValue ? sprintIteration.SprintStart.Value : DateTime.MinValue,
            };

            return(sprintProgressDto);
        }
 private async Task LoopThruSprintDays(SprintProgressDto sprintProgressDto, EffortType effortType)
 {
     //loop thru each of the 10 sprint days
     for (var sprintDateWithoutTime = sprintProgressDto.SprintStart;
          sprintDateWithoutTime <= sprintProgressDto.SprintEnd;
          sprintDateWithoutTime = sprintDateWithoutTime.AddDays(1))
     {
         if (IsWeekday(sprintDateWithoutTime))
         {
             await PopulateSprintProgressDto(sprintProgressDto, effortType, sprintDateWithoutTime);
         }
     }
 }
        private async Task PopulateSprintProgressDto(SprintProgressDto sprintProgressDto, EffortType effortType, DateTime sprintDateWithoutTime)
        {
            var sprintDateWithTime = GetSprintDateWithTime(sprintDateWithoutTime);

            //get work item ids (json response) in the sprint on this specific date
            var workItemJson = await GetWorkItemData(sprintDateWithTime);

            //set up date format
            var sprintDateYMDTHMSMSZ = GetFormattedDate(sprintDateWithTime);

            //deserialize to a list of ids/urls for that date
            var workItemsInSprintOnSprintDate = _workItemProcessor.GetWorkItemsByJson(workItemJson).ToList();

            await PopulateSprintProgressDto(sprintProgressDto, effortType, sprintDateWithTime, sprintDateYMDTHMSMSZ, workItemsInSprintOnSprintDate);
        }
        private SprintProgressVm GetSprintProgressVm(SprintProgressDto sprintProgressDto)
        {
            var sprintProgressVm = new SprintProgressVm();

            sprintProgressVm.IterationNumber = sprintProgressDto.IterationNumber;
            sprintProgressVm.SprintEnd       = sprintProgressDto.SprintEnd;
            sprintProgressVm.SprintStart     = sprintProgressDto.SprintStart;
            sprintProgressVm.WorkItemVms     = new List <WorkItemVm>();

            if (sprintProgressDto.WorkItemDtos != null && sprintProgressDto.WorkItemDtos.Any())
            {
                foreach (var workItemDto in sprintProgressDto.WorkItemDtos)
                {
                    var workItemVm = GetWorkItemVm(workItemDto);
                    sprintProgressVm.WorkItemVms.Add(workItemVm);
                }
            }

            return(sprintProgressVm);
        }
        private async Task <SprintProgressDto> GetSprintProgressDtoLive()
        {
            SprintProgressDto sprintProgressDto;

            try
            {
                var data = await GatherData();

                var effortType = data.Item1;
                sprintProgressDto = data.Item2;

                await LoopThruSprintDays(sprintProgressDto, effortType);
            }
            catch (Exception ex)
            {
                var exceptionMessage = $"ex.message {ex.Message}";
                Console.WriteLine(exceptionMessage);
                sprintProgressDto = new SprintProgressDto {
                    IterationNumber = exceptionMessage
                };
            }

            return(sprintProgressDto);
        }
Beispiel #9
0
        public static SprintProgressDto GetSprintProgressDtoTest()
        {
            SprintProgressDto sprintProgressDto;

            var now = DateTime.Now.Date.AddDays(-1).AddHours(22).AddMinutes(59).AddSeconds(59);
            var i   = -4;

            sprintProgressDto = new SprintProgressDto
            {
                IterationNumber = "Sprint 177",
                SprintEnd       = now.AddDays(14),
                SprintStart     = now.Date.AddDays(i),
                WorkItemDtos    = new List <WorkItemDto>
                {
                    // Day 1
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 0), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 0), Effort = 0, Id = 1, State = "done"
                    },

                    // Day 2
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 1), Effort = 1000, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 1), Effort = 20, Id = 1, State = "done"
                    },

                    // Day 3
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 2), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 2), Effort = 18, Id = 1, State = "done"
                    },

                    // Day 4
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 3), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 3), Effort = 41, Id = 1, State = "done"
                    },

                    // Day 5+
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 4), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 4), Effort = 50, Id = 1, State = "done"
                    },

                    new WorkItemDto {
                        AsOf = now.AddDays(i + 5), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 5), Effort = 75, Id = 1, State = "done"
                    },

                    new WorkItemDto {
                        AsOf = now.AddDays(i + 6), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 6), Effort = 80, Id = 1, State = "done"
                    },

                    new WorkItemDto {
                        AsOf = now.AddDays(i + 7), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 7), Effort = 77, Id = 1, State = "done"
                    },

                    new WorkItemDto {
                        AsOf = now.AddDays(i + 8), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 8), Effort = 93, Id = 1, State = "done"
                    },

                    new WorkItemDto {
                        AsOf = now.AddDays(i + 9), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 9), Effort = 95, Id = 1, State = "done"
                    },

                    new WorkItemDto {
                        AsOf = now.AddDays(i + 10), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 10), Effort = 100, Id = 1, State = "done"
                    },

                    new WorkItemDto {
                        AsOf = now.AddDays(i + 11), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 11), Effort = 100, Id = 1, State = "done"
                    },

                    new WorkItemDto {
                        AsOf = now.AddDays(i + 12), Effort = 100, Id = 1, State = "approved"
                    },
                    new WorkItemDto {
                        AsOf = now.AddDays(i + 12), Effort = 100, Id = 1, State = "done"
                    },
                }
            };

            for (int j = 0; j < 22; j++)
            {
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 0), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 1), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 2), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 3), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 4), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 5), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 6), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 7), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 8), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 9), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 10), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 11), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 12), Effort = 0, Id = 1, State = "approved"
                });
            }

            //4 work items added in final days of sprint
            for (int k = 0; k < 4; k++)
            {
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 8), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 9), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 10), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 11), Effort = 0, Id = 1, State = "approved"
                });
                sprintProgressDto.WorkItemDtos.Add(new WorkItemDto {
                    AsOf = now.AddDays(i + 12), Effort = 0, Id = 1, State = "approved"
                });
            }

            return(sprintProgressDto);
        }