Exemplo n.º 1
0
 private static void AddCalendarData( Sprint sprint )
 {
     var random = new Random();
      var date = (DateTime)sprint.StartDate;
      while (date <= sprint.EndDate)
      {
     var entry = new SprintCalendarEntry()
     {
        Sprint = sprint,
        HistoryDate = date,
        PointsRemaining = random.Next( 1, 42 )
     };
     ((IList<SprintCalendarEntry>)sprint.Calendar).Add( entry );
     date = date.AddDays( 1 );
      }
 }
        public void Update( Sprint sprint )
        {
            Log.Debug( "Updating Sprint Calendar" );

             if (sprint.StartDate == null || sprint.EndDate == null ||
             ((DateTime)sprint.EndDate).Date < DateTime.Now.Date)
             {
            return;
             }

             var startDate = ((DateTime)sprint.StartDate).Date;
             UpdateCalendar( sprint,
            (DateTime.Now.Date < startDate) ? startDate :
            DateTime.Now.Date );

             Log.Debug( "Sprint Calendar Update Complete" );
        }
        public void Reset( Sprint sprint )
        {
            Log.Debug( "Reset Sprint Calendar" );

             ClearCalendar( sprint );

             if (sprint.StartDate == null || sprint.EndDate == null)
             {
            return;
             }

             var startDate = ((DateTime)sprint.StartDate).Date;
             var endDate = ((DateTime)sprint.EndDate).Date;
             UpdateCalendar( sprint,
            (DateTime.Now.Date < startDate) ? startDate :
            (DateTime.Now.Date > endDate) ? endDate :
            DateTime.Now.Date );

             Log.Debug( "Sprint Calendar Reset Complete" );
        }
 private void CreateCalendarEntry( Sprint sprint, DateTime date )
 {
     var p = PointsRemaining( sprint, date );
      var s = new SprintCalendarEntry()
      {
     Sprint = sprint,
     HistoryDate = date,
     PointsRemaining = p
      };
      sprint.Calendar.Add( s );
 }
 private void ClearCalendar( Sprint sprint )
 {
     var session = _sessionFactory.GetCurrentSession();
      foreach (var item in sprint.Calendar)
      {
     session.Delete( item );
      }
      sprint.Calendar.Clear();
 }
        private void UpdateCalendar( Sprint sprint, DateTime throughDate )
        {
            GetSprintTasks( sprint );

             var date = ((DateTime)sprint.StartDate);
             while (date < throughDate)
             {
            if (sprint.Calendar.SingleOrDefault( x => x.HistoryDate == date ) == null)
            {
               CreateCalendarEntry( sprint, date );
            }
            date = date.AddDays( 1 );
             }
             CreateOrUpdateCalendarEntry( sprint, throughDate );
        }
        private int PointsRemaining( Sprint sprint, DateTime date )
        {
            int points = 0;
             foreach (var task in _sprintTasks)
             {
            var snapshot = task.PointsHistory
               .OrderBy( x => x.HistoryDate )
               .LastOrDefault( x => x.HistoryDate <= date );
            if (snapshot != null)
            {
               points += snapshot.PointsRemaining;
            }
             }

             return points;
        }
 private void GetSprintTasks( Sprint sprint )
 {
     var _session = _sessionFactory.GetCurrentSession();
      _sprintTasks = _session.Query<WorkItem>()
     .Where( x => x.Sprint.Id == sprint.Id && x.WorkItemType.Category != WorkItemTypeCategory.BacklogItem )
     .ToList();
 }
 private void CreateOrUpdateCalendarEntry( Sprint sprint, DateTime date )
 {
     var entry = sprint.Calendar.SingleOrDefault( x => x.HistoryDate.Date == date.Date );
      if (entry != null)
      {
     entry.PointsRemaining = PointsRemaining( sprint, date );
      }
      else
      {
     CreateCalendarEntry( sprint, date );
      }
 }
 private int CalendarHash( Sprint sprint )
 {
     var hash = 0;
      foreach (var e in sprint.Calendar)
      {
     hash += e.GetHashCode();
      }
      return hash;
 }
 private void AssertSprintCalendar( Sprint sprint, IEnumerable<WorkItem> tasks, int day )
 {
     var date = ((DateTime)sprint.StartDate).AddDays( day );
      var pointsRemaining = 0;
      foreach (var task in tasks)
      {
     pointsRemaining += task.PointsHistory.OrderBy( x => x.HistoryDate ).Last( x => x.HistoryDate <= date ).PointsRemaining;
      }
      Assert.AreEqual( pointsRemaining, sprint.Calendar.Single( x => x.HistoryDate == date ).PointsRemaining );
 }
Exemplo n.º 12
0
        private WorkItemsListForSprintViewModel CreateTasksForSprintViewModel( Sprint sprint )
        {
            var model = new WorkItemsListForSprintViewModel()
             {
            Id = sprint.Id,
            Name = sprint.Name
             };

             using (var tx = _session.BeginTransaction())
             {
            model.WorkItems = _session.Query<WorkItem>()
               .Where( x => x.Project.Id == sprint.Project.Id && x.WorkItemType.Category != WorkItemTypeCategory.BacklogItem && x.ParentWorkItem == null && (x.Sprint == null || x.Sprint.Id == sprint.Id) )
               .Select( x => new SprintWorkItemViewModel()
               {
                  Id = x.Id,
                  Name = x.Name,
                  Description = x.Description,
                  StatusName = x.Status.Name,
                  WorkItemTypeName = x.WorkItemType.Name,
                  IsInTargetSprint = (x.Sprint != null)
               } )
               .ToList();

            tx.Commit();
             }

             return model;
        }
Exemplo n.º 13
0
 private SprintEditorViewModel CreateSprintEditorViewModel( Sprint model )
 {
     return new SprintEditorViewModel()
      {
     Id = model.Id,
     Name = model.Name,
     Description = model.Description,
     StatusId = model.Status.Id,
     StatusName = model.Status.Name,
     ProjectId = model.Project.Id,
     ProjectName = model.Project.Name,
     StartDate = model.StartDate,
     EndDate = model.EndDate,
     CreatedByUserId = model.CreatedByUser.Id,
     Capacity = model.Capacity
      };
 }
Exemplo n.º 14
0
 private static void AssertModelAndViewModelPropertiesEqual( Sprint model, SprintEditorViewModel viewModel )
 {
     Assert.AreEqual( model.Id, viewModel.Id );
      Assert.AreEqual( model.Name, viewModel.Name );
      Assert.AreEqual( model.Description, viewModel.Description );
      Assert.AreEqual( model.Goal, viewModel.Goal );
      Assert.AreEqual( model.StartDate.ToString(), viewModel.StartDate.ToString() );
      Assert.AreEqual( model.EndDate.ToString(), viewModel.EndDate.ToString() );
      Assert.AreEqual( model.Capacity, viewModel.Capacity );
 }