private void BindViewModel() { DateTime now = DateTime.Parse(@"2020-10-20 00:00:00"); TimelineTask task1 = new TimelineTask(); task1.StartTime = now.AddHours(1); task1.EndTime = now.AddHours(6); TimelineTask task2 = new TimelineTask(); task2.StartTime = now.AddHours(5); task2.EndTime = now.AddHours(9); TimelineTask task3 = new TimelineTask(); task3.StartTime = now.AddHours(6); task3.EndTime = now.AddHours(12); TimelineViewModel model = new TimelineViewModel(); model.Now = now; model.Start = now; model.End = now.AddDays(1); model.Zoom = 0.1; model.ZoomPercent = 0.1; model.Tasks.Add(task1); model.Tasks.Add(task2); model.Tasks.Add(task3); this.DataContext = model; }
private static bool TimelineTasksDiffer(TimelineTask task1, TimelineTask task2) { if ((!task1.ACID.Equals(task2.ACID) || (!task1.StepId.Equals(task2.StepId)) || (!task1.StepDescription.Equals(task2.StepDescription)) || (!task1.StageId.Equals(task2.StageId)) || (!task1.StageDescription.Equals(task2.StageDescription)) || (!task1.ClickUpSpaceId.Equals(task2.ClickUpSpaceId)) || (!task1.ClickUpFolderId.Equals(task2.ClickUpFolderId)) || (!task1.ClickUpTaskId.Equals(task2.ClickUpTaskId)) || (!task1.ActualDate.Equals(task2.ActualDate)) || (!task1.DueDate.Equals(task2.DueDate)))) { return(true); } return(false); }
private static IList <TimelineEntryViewModel> ConvertToTimelineEntryViewModels(TimelineTask task) { var timelineEntries = new List <TimelineEntryViewModel>(); if (task?.TimelineSnapshots == null || !task.TimelineSnapshots.Any()) { return(timelineEntries); } // Each task can contain multiple snapshots of what the schedules and completion metrics looked like at a point in time foreach (var snapshot in task.TimelineSnapshots) { if (snapshot.Schedules != null && snapshot.Schedules.Any()) { foreach (var schedule in snapshot.Schedules) { // Check that the schedule is within this snapshot. if (schedule.LocalDateTime >= snapshot.EffectiveStartInstant.InUtc().LocalDateTime&& schedule.LocalDateTime <= snapshot.EffectiveEndInstant.InUtc().LocalDateTime) { // Add a timeline entry for the schedule timelineEntries.Add(new TimelineEntryViewModel { TaskId = task.TaskId, TaskName = task.TaskName, TaskImageUrl = task.TaskImageUrl, LocalDateTime = schedule.LocalDateTime, ScheduleType = schedule.Type }); // Add any out-of-window task occurrences to show on the timeline schedule.Occurrences?.Where(o => !o.InWindow).ToList().ForEach(occurrence => AddOccurrence(timelineEntries, occurrence, task));; } } } // Add any unscheduled task occurrences to show on the timeline snapshot.UnscheduledOccurrences?.ForEach(occurrence => AddOccurrence(timelineEntries, occurrence, task)); } return(timelineEntries); }
private static void AddOccurrence(List <TimelineEntryViewModel> timelineEntries, TimelineScheduleOccurrence occurrence, TimelineTask task) { // Don't add another entry if this occurrence has already been added to the timeline if (timelineEntries.Any(t => t.OccurrenceId.HasValue && t.OccurrenceId.Value == occurrence.Id)) { return; } timelineEntries.Add(new TimelineEntryViewModel { TaskId = task.TaskId, TaskName = task.TaskName, TaskImageUrl = task.TaskImageUrl, LocalDateTime = occurrence.LocalDateTime, ScheduleType = TimelineScheduleType.Unscheduled, OccurrenceId = occurrence.Id }); }