Пример #1
0
        /// <summary>
        /// Validates all properties
        /// </summary>
        public override void Validate()
        {
            base.Validate();
            TemperatureSettings.Validate();
            if (LiftBuildSettings != null)
            {
                LiftBuildSettings.Validate();
            }
            if (Filter != null)
            {
                Filter.Validate();
            }

            if (OverrideStartUTC.HasValue || OverrideEndUTC.HasValue)
            {
                if (OverrideStartUTC.HasValue && OverrideEndUTC.HasValue)
                {
                    if (OverrideStartUTC.Value > OverrideEndUTC.Value)
                    {
                        throw new ServiceException(HttpStatusCode.BadRequest,
                                                   new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                               "Override startUTC must be earlier than override endUTC"));
                    }
                }
                else
                {
                    throw new ServiceException(HttpStatusCode.BadRequest,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                           "If using an override date range both dates must be provided"));
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Validates the request and throws if validation fails.
        /// </summary>
        public override void Validate()
        {
            const int NUM_TOLERANCES = 7;

            base.Validate();

            if (CutFillTolerances?.Length != NUM_TOLERANCES)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       $"{NUM_TOLERANCES} tolerances must be specified for cut-fill details"));
            }

            Filter?.Validate();

            LiftBuildSettings?.Validate();

            if (DesignDescriptor != null)
            {
                DesignDescriptor.Validate();
            }
            else
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "Design must be specified for cut-fill details"));
            }
        }
Пример #3
0
 public override void Validate()
 {
     LiftBuildSettings?.Validate();
     AdditionalSpatialFilter?.Validate();
     TopFilter?.Validate();
     BaseFilter?.Validate();
 }
Пример #4
0
        /// <summary>
        /// Validates all properties
        /// </summary>
        public override void Validate()
        {
            base.Validate();

            LiftBuildSettings?.Validate();
            Filter?.Validate();
        }
Пример #5
0
        public void ValidatePassCountTargetRangeFailTest()
        {
            //min pass count target > max pass count target
            LiftBuildSettings settings = new LiftBuildSettings(
                new CCVRangePercentage(30.0, 70.0), false, 0.0, 0.0, 0.2f, LiftDetectionType.Automatic,
                LiftThicknessType.Compacted, new MDPRangePercentage(35.0, 75.0), false, 0.0f, 0, 0,
                new TargetPassCountRange(10, 1), new TemperatureWarningLevels(500, 700), false, _liftThicknessTarget, null);

            Assert.ThrowsException <ServiceException>(() => settings.Validate());
        }
Пример #6
0
        public override void Validate()
        {
            base.Validate();
            ValidatePalettes(Palettes, Mode);
            LiftBuildSettings?.Validate();

            ValidateDesign(DesignDescriptor, Mode, ComputeVolType);

            if (Mode == DisplayMode.VolumeCoverage)
            {
                ValidateVolumesFilters(ComputeVolType, Filter1, FilterId1, Filter2, FilterId2);
            }
        }
Пример #7
0
        /// <summary>
        /// Validates all properties
        /// </summary>
        public override void Validate()
        {
            base.Validate();
            ValidatePalettes(Palettes, Mode);

            //Compaction settings
            LiftBuildSettings?.Validate();

            //Volumes
            //mode == DisplayMode.VolumeCoverage
            //computeVolNoChangeTolerance and computeVolType must be provided but since not nullable types they always will have a value anyway
            ValidateDesign(DesignDescriptor, Mode, ComputeVolumesType);

            //Summary volumes: v1 has mode VolumeCoverage, v2 has mode CutFill but computeVolType is set
            if (Mode == DisplayMode.VolumeCoverage ||
                (Mode == DisplayMode.CutFill &&
                 (ComputeVolumesType == VolumesType.Between2Filters ||
                  ComputeVolumesType == VolumesType.BetweenDesignAndFilter ||
                  ComputeVolumesType == VolumesType.BetweenFilterAndDesign)))
            {
                ValidateVolumesFilters(ComputeVolumesType, this.Filter1, this.FilterId1, this.Filter2, this.FilterId2);
            }

            if (BoundBoxLatLon == null && BoundBoxGrid == null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "Bounding box required either in lat/lng or grid coordinates"));
            }

            if (BoundBoxLatLon != null && BoundBoxGrid != null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "Only one bounding box is allowed"));
            }

            if (Mode == DisplayMode.TargetThicknessSummary && LiftBuildSettings.LiftThicknessTarget == null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "For this mode LiftThickness Target in LIftBuildSettings must be specified."));
            }

            if (Mode == DisplayMode.TargetSpeedSummary && LiftBuildSettings.MachineSpeedTarget == null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "For this mode SpeedSummary Target in LiftBuildSettings must be specified."));
            }
        }
Пример #8
0
        public void ValidateSuccessTest()
        {
            LiftBuildSettings settings = new LiftBuildSettings(
                new CCVRangePercentage(30.0, 70.0), false, 0.0, 0.0, 0.2f, LiftDetectionType.Automatic,
                LiftThicknessType.Compacted, new MDPRangePercentage(35.0, 75.0), false, 0.0f, 0, 0, null, null, null, _liftThicknessTarget, null);

            settings.Validate();

            settings = new LiftBuildSettings(
                new CCVRangePercentage(30.0, 70.0), false, 0.0, 0.0, 0.2f, LiftDetectionType.Automatic,
                LiftThicknessType.Compacted, new MDPRangePercentage(35.0, 75.0),
                true, 2.0f, 140, 125, new TargetPassCountRange(3, 3),
                new TemperatureWarningLevels(300, 800), false, _liftThicknessTarget, null);
            settings.Validate();
        }
Пример #9
0
        /// <summary>
        /// Validates properties.
        /// </summary>
        ///
        public override void Validate()
        {
            base.Validate();

            // Compaction settings
            LiftBuildSettings?.Validate();

            if (ReportCutFill)
            {
                ValidateDesign(DesignFile, DisplayMode.CutFill, VolumesType.None);
            }

            if (!(ReportPassCount || ReportTemperature || ReportMDP || ReportCutFill || ReportCMV || ReportElevation))
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "There are no selected fields to be reported on"));
            }
        }
Пример #10
0
        /// <summary>
        /// Validates the request and throws if validation fails.
        /// </summary>
        public override void Validate()
        {
            base.Validate();
            // Validate the profile type...
            if (!Enumerable.Range((int)ProductionDataType.All, (int)ProductionDataType.CCVChange + 1).Contains((int)ProfileType))
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       $"Profile type {(int)ProfileType} is out of range. It should be between: {(int)ProductionDataType.All} and {(int)ProductionDataType.CCVChange}."));
            }

            if (Filter != null)
            {
                Filter.Validate();

                if (FilterID.HasValue && FilterID.Value <= 0)
                {
                    throw new ServiceException(HttpStatusCode.BadRequest,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                           $"Filter ID {FilterID.Value} should be greater than zero."));
                }
            }

            if (AlignmentDesign == null && GridPoints == null && WGS84Points == null)
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "Either a linear or alignment based profile must be provided."));
            }

            if (AlignmentDesign != null && (GridPoints != null || WGS84Points != null))
            {
                throw new ServiceException(HttpStatusCode.BadRequest,
                                           new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                       "Only one type, either a linear or alignment based profile must be provided."));
            }

            if (AlignmentDesign != null)
            {
                // Validate alignment design parts...
                if (!StartStation.HasValue || !EndStation.HasValue)
                {
                    throw new ServiceException(HttpStatusCode.BadRequest,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                           "If using an alignment design for profiling, the alignment file, start and end station must be provided."));
                }

                AlignmentDesign.Validate();
            }
            else
            {
                // Validate profile points...
                if (GridPoints != null && WGS84Points != null)
                {
                    throw new ServiceException(HttpStatusCode.BadRequest,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                           "The profile line requires series either grid or WGS84 points."));
                }

                if (GridPoints == null && WGS84Points == null)
                {
                    throw new ServiceException(HttpStatusCode.BadRequest,
                                               new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError,
                                                                           "The profile line should be represented by series either grid or WGS84 points, not both."));
                }
            }

            LiftBuildSettings?.Validate();
        }