private List <Thing> EvaluateAllLazyLoadedItems()
 {
     return(_client.LazyGet <Thing, GetThings, ThingResults>(new GetThings(), progressReporter: new ConsoleProgressReporter()).DomainObjects.ToList());
 }
Exemplo n.º 2
0
 private List <Thing> EvaluateAllLazyLoadedItems()
 {
     return(_client.LazyGet <Thing, GetThings, ThingResults>(new GetThings()).DomainObjects.ToList());
 }
Exemplo n.º 3
0
        private void LoadTripsWithPlannedVisits()
        {
            var plannedVisits = _client.LazyGet <FieldVisitSimple, HackedGetFieldVisits, SearchResultFieldVisitSimple>(
                new HackedGetFieldVisits
            {
                PlanningStatuses = new List <string> {
                    $"{PlanningStatusType.PLANNED}"
                },
            }).DomainObjects
                                .ToList();

            var plannedTripVisits = plannedVisits
                                    .Where(v => v.StartTime.HasValue && v.FieldTrip != null)
                                    .ToList();

            var plannedTripIds = new HashSet <string>(plannedTripVisits
                                                      .Select(v => v.FieldTrip.Id)
                                                      .Distinct());

            Info($"Fetching {"visit detail".ToQuantity(plannedTripVisits.Count)} ...");

            var stopwatch = Stopwatch.StartNew();

            var plannedVisitsWithStartTimes = plannedTripVisits
                                              .Select(v => _client.Get(new GetFieldVisit {
                Id = v.Id
            }))
                                              .ToList();

            Info($"Fetched {"visit".ToQuantity(plannedTripVisits.Count)} in {stopwatch.Elapsed.Humanize(2)}");

            var tripsWithPlannedVisits = plannedTripIds
                                         .ToDictionary(
                tripId => tripId,
                tripId => plannedVisitsWithStartTimes
                .Where(v => tripId == v.FieldTrip.Id && IsCandidateVisit(v))
                .ToList());

            var items = tripsWithPlannedVisits
                        .SelectMany(t => t.Value)
                        .Select(v => new TableItem
            {
                Trip      = v.FieldTrip.CustomId,
                Start     = v.StartTime.Value.ToDateTimeUtc().Add(DateTimeOffset.Now.Offset),
                Location  = v.SamplingLocation.CustomId,
                Specimens = $"{v.PlannedActivities.SelectMany(a => a.ActivityTemplate.SpecimenTemplates).Count()} specimens",
                Visit     = v
            })
                        .OrderBy(i => i.Trip)
                        .ThenBy(i => i.Start)
                        .ToList();

            tripDataGridView.DataSource          = items;
            tripDataGridView.Columns[0].SortMode = DataGridViewColumnSortMode.Automatic;
            tripDataGridView.Columns[1].SortMode = DataGridViewColumnSortMode.Automatic;
            tripDataGridView.Columns[2].SortMode = DataGridViewColumnSortMode.Automatic;
            tripDataGridView.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
            tripDataGridView.Columns[4].Visible  = false;
            tripDataGridView.Enabled             = true;

            Info($"{"trip".ToQuantity(tripsWithPlannedVisits.Sum(k => k.Value.Count))} with planned visits.");
        }