コード例 #1
0
        /// <summary>
        /// Perform filtering on a set of surveyed surfaces according to the supplied time constraints.
        /// Note: The list of filtered surveyed surfaces is assumed to be empty at the point it is passed to this method
        /// </summary>
        public void FilterSurveyedSurfaceDetails(bool hasTimeFilter,
                                                 DateTime startTime, DateTime endTime,
                                                 bool excludeSurveyedSurfaces,
                                                 ISurveyedSurfaces filteredSurveyedSurfaceDetails,
                                                 Guid[] exclusionList)
        {
            if (excludeSurveyedSurfaces)
            {
                return;
            }

            if (startTime.Kind != DateTimeKind.Utc || endTime.Kind != DateTimeKind.Utc)
            {
                throw new ArgumentException("StartTime and EndTime must be UTC date times");
            }

            if (!hasTimeFilter && (exclusionList?.Length ?? 0) == 0)
            {
                filteredSurveyedSurfaceDetails.Assign(this);
                return;
            }

            filteredSurveyedSurfaceDetails.Clear();
            foreach (var ss in this)
            {
                if (!hasTimeFilter)
                {
                    if (exclusionList == null || !exclusionList.Any(x => x == ss.ID)) // if SS not excluded from project
                    {
                        filteredSurveyedSurfaceDetails.Add(ss);                       // Formerly ss.Clone
                    }
                }
                else
                {
                    if (ss.AsAtDate >= startTime && ss.AsAtDate <= endTime &&
                        (exclusionList == null || !exclusionList.Any(x => x == ss.ID))) // if SS not excluded from project
                    {
                        filteredSurveyedSurfaceDetails.Add(ss);                         // Formerly ss.Clone
                    }
                }
            }
        }