示例#1
0
        private static int PutBackFlaggedObservations(ISamplesClient client, Context context,
                                                      List <Observation> invalidObservations)
        {
            var flag         = context.Flag;
            var flaggedCount = 0;

            foreach (var invalidObservation in invalidObservations)
            {
                if (invalidObservation.LabResultDetails?.QualityFlag == flag)
                {
                    continue;
                }

                client.Put(new PutObservation
                {
                    Id = invalidObservation.Id,
                    LabResultDetails = new LabResultDetails
                    {
                        QualityFlag = flag
                    }
                });

                Log.Info($"Invalid observation:'{invalidObservation.Id}' is flagged.");
                flaggedCount++;
            }

            return(flaggedCount);
        }
示例#2
0
        private void ScheduleVisit(FieldVisit visit)
        {
            // Mark the visit as in progress
            var updatedVisit = _client.Put(new PutFieldVisit
            {
                Id             = visit.Id,
                PlanningStatus = PlanningStatusType.IN_PROGRESS
            });

            var message = $"Trip '{visit.FieldTrip.CustomId}' on {visit.StartTime} @ '{visit.SamplingLocation.CustomId}': ";

            foreach (var plannedActivity in visit.PlannedActivities.Where(a => a.ActivityTemplate.SpecimenTemplates.Any()))
            {
                var activityTemplate = plannedActivity.ActivityTemplate;

                message += $" '{activityTemplate.CustomId}' with {activityTemplate.SpecimenTemplates.Count} specimens {string.Join(", ", activityTemplate.SpecimenTemplates.Select(s => s.Name))}";

                var activity = _client.Post(new PostSpecimensFromPlannedActivity
                {
                    VisitId          = visit.Id,
                    Id               = plannedActivity.Id,
                    ActivityTemplate = new ActivityTemplate
                    {
                        Id                = activityTemplate.Id,
                        Medium            = activityTemplate.Medium,
                        SpecimenTemplates = null,
                        Type              = activityTemplate.Type
                    },
                    ActivityType = plannedActivity.ActivityType
                });
            }

            Info(message);
        }