/// <summary> /// Validates properties. /// </summary> public override void Validate() { base.Validate(); if (AlignmentFile == null) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Alignment file must be specified for station and offset report.")); } AlignmentFile?.Validate(); if (this.CrossSectionInterval < ValidationConstants3D.MIN_SPACING_INTERVAL || this.CrossSectionInterval > ValidationConstants3D.MAX_SPACING_INTERVAL) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, $"Interval must be >= {ValidationConstants3D.MIN_SPACING_INTERVAL}m and <= {ValidationConstants3D.MAX_SPACING_INTERVAL}m. Actual value: {this.CrossSectionInterval}")); } if (Offsets == null || Offsets.Length == 0) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Offsets must be specified for station and offset report.")); } // Start and end stations negative value are allowed... if (StartStation > EndStation) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Invalid station range for station and offset report.")); } }
public bool Equals(FilterResult other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Id.Equals(other.Id) && Uid.Equals(other.Uid) && string.Equals(Name, other.Name) && string.Equals(Description, other.Description) && StartUtc.Equals(other.StartUtc) && EndUtc.Equals(other.EndUtc) && OnMachineDesignId == other.OnMachineDesignId && OnMachineDesignName == other.OnMachineDesignName && AssetIDs.ScrambledEquals(other.AssetIDs) && VibeStateOn == other.VibeStateOn && CompactorDataOnly.Equals(other.CompactorDataOnly) && ElevationType == other.ElevationType && PolygonLL.ScrambledEquals(other.PolygonLL) && PolygonGrid.ScrambledEquals(other.PolygonGrid) && ForwardDirection == other.ForwardDirection && (AlignmentFile == null ? other.AlignmentFile == null : AlignmentFile.Equals(other.AlignmentFile)) && StartStation.Equals(other.StartStation) && EndStation.Equals(other.EndStation) && LeftOffset.Equals(other.LeftOffset) && RightOffset.Equals(other.RightOffset) && LayerType.Equals(other.LayerType) && (LayerDesignOrAlignmentFile == null ? other.LayerDesignOrAlignmentFile == null : LayerDesignOrAlignmentFile.Equals(other.LayerDesignOrAlignmentFile)) && BenchElevation.Equals(other.BenchElevation) && LayerNumber == other.LayerNumber && LayerThickness.Equals(other.LayerThickness) && ContributingMachines.ScrambledEquals(other.ContributingMachines) && SurveyedSurfaceExclusionList.ScrambledEquals(other.SurveyedSurfaceExclusionList) && ExcludedSurveyedSurfaceUids.ScrambledEquals(other.ExcludedSurveyedSurfaceUids) && ReturnEarliest.Equals(other.ReturnEarliest) && GpsAccuracy.Equals(other.GpsAccuracy) && GpsAccuracyIsInclusive.Equals(other.GpsAccuracyIsInclusive) && BladeOnGround.Equals(other.BladeOnGround) && TrackMapping.Equals(other.TrackMapping) && WheelTracking.Equals(other.WheelTracking) && (DesignFile == null ? other.DesignFile == null : DesignFile.Equals(other.DesignFile)) && AutomaticsType == other.AutomaticsType && TemperatureRangeMin.Equals(other.TemperatureRangeMin) && TemperatureRangeMax.Equals(other.TemperatureRangeMax) && PassCountRangeMin.Equals(other.PassCountRangeMin) && PassCountRangeMax.Equals(other.PassCountRangeMax)); }
/// <summary> /// Validates all properties /// </summary> public void Validate() { if (PolygonGrid != null) { foreach (var pt in PolygonGrid) { pt.Validate(); } } AlignmentFile?.Validate(); LayerDesignOrAlignmentFile?.Validate(); DesignFile?.Validate(); if (ContributingMachines != null) { foreach (var machine in ContributingMachines) { machine.Validate(); } } //Check date range parts if (StartUtc.HasValue || EndUtc.HasValue) { if (StartUtc.HasValue && EndUtc.HasValue) { if (StartUtc.Value > EndUtc.Value) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "StartUTC must be earlier than EndUTC")); } } else { if (!AsAtDate.HasValue || AsAtDate.Value == false) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "If using a date range both dates must be provided")); } if (!EndUtc.HasValue) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Either EndUTC or DateRangeType must be provided for an as-at date filter")); } } } if (AsAtDate.HasValue) { bool valid = EndUtc.HasValue || DateRangeType.HasValue && DateRangeType.Value != MasterData.Models.Internal.DateRangeType.Custom;//custom must have end UTC if (!valid) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Either EndUTC or DateRangeType must be provided for an as-at date filter")); } } //Check alignment filter parts if (AlignmentFile != null || StartStation.HasValue || EndStation.HasValue || LeftOffset.HasValue || RightOffset.HasValue) { if (AlignmentFile == null || !StartStation.HasValue || !EndStation.HasValue || !LeftOffset.HasValue || !RightOffset.HasValue) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "If using an alignment filter, alignment file, start and end station, left and right offset must be provided")); } AlignmentFile.Validate(); } //Check layer filter parts if (LayerNumber.HasValue && !LayerType.HasValue) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "To use the layer number filter, layer type must be specified")); } if (LayerType.HasValue) { switch (LayerType.Value) { case FilterLayerMethod.OffsetFromDesign: case FilterLayerMethod.OffsetFromBench: case FilterLayerMethod.OffsetFromProfile: if (LayerType.Value == FilterLayerMethod.OffsetFromBench) { if (!BenchElevation.HasValue) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "If using an offset from bench filter, bench elevation must be provided")); } } else { if (LayerDesignOrAlignmentFile == null) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "If using an offset from design or profile filter, design or alignment file must be provided")); } LayerDesignOrAlignmentFile.Validate(); } if (!LayerNumber.HasValue || !LayerThickness.HasValue) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "If using an offset from bench, design or alignment filter, layer number and layer thickness must be provided")); } break; case FilterLayerMethod.TagfileLayerNumber: if (!LayerNumber.HasValue) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "If using a tag file layer filter, layer number must be provided")); } break; } } //Check boundary if provided //Raptor handles any weird boundary you give it and automatically closes it if not closed already therefore we just need to check we have at least 3 points if (PolygonLL != null && PolygonLL.Count < 3) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Too few points for filter polygon")); } if (PolygonGrid != null && PolygonGrid.Count < 3) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Too few points for filter polygon")); } if (PolygonLL != null && PolygonLL.Count > 0 && PolygonGrid != null && PolygonGrid.Count > 0) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Only one type of filter boundary can be defined at one time")); } if (TemperatureRangeMin.HasValue != TemperatureRangeMax.HasValue) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Invalid temperature range filter. Both minimum and maximum must be provided.")); } if (TemperatureRangeMin.HasValue && TemperatureRangeMax.HasValue) { if (TemperatureRangeMin.Value > TemperatureRangeMax.Value) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Invalid temperature range filter. Minimum must be less than maximum.")); } if (TemperatureRangeMin.Value < ValidationConstants.MIN_TEMPERATURE || TemperatureRangeMin.Value > ValidationConstants.MAX_TEMPERATURE || TemperatureRangeMax.Value < ValidationConstants.MIN_TEMPERATURE || TemperatureRangeMax.Value > ValidationConstants.MAX_TEMPERATURE) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, $"Invalid temperature range filter. Range must be between {ValidationConstants.MIN_TEMPERATURE} and {ValidationConstants.MAX_TEMPERATURE}.")); } } if (PassCountRangeMin.HasValue != PassCountRangeMax.HasValue) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Invalid pass count range filter. Both minimum and maximum must be provided.")); } if (PassCountRangeMin.HasValue && PassCountRangeMax.HasValue) { if (PassCountRangeMin.Value > PassCountRangeMax.Value) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, "Invalid pass count range filter. Minimum must be less than maximum.")); } if (PassCountRangeMin.Value < ValidationConstants.MIN_TEMPERATURE || PassCountRangeMin.Value > ValidationConstants.MAX_TEMPERATURE || PassCountRangeMax.Value < ValidationConstants.MIN_TEMPERATURE || PassCountRangeMax.Value > ValidationConstants.MAX_TEMPERATURE) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, $"Invalid pass count range filter. Range must be between {ValidationConstants.MIN_PASS_COUNT} and {ValidationConstants.MAX_PASS_COUNT}.")); } } if (SurveyedSurfaceExclusionList != null && SurveyedSurfaceExclusionList.Count > 0) { foreach (var id in SurveyedSurfaceExclusionList) { if (id <= 0) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, $"Invalid excluded surveyed surface id {id}")); } } } if (ExcludedSurveyedSurfaceUids != null && ExcludedSurveyedSurfaceUids.Count > 0) { foreach (var uid in ExcludedSurveyedSurfaceUids) { if (uid == Guid.Empty) { throw new ServiceException(HttpStatusCode.BadRequest, new ContractExecutionResult(ContractExecutionStatesEnum.ValidationError, $"Invalid excluded surveyed surface id {uid}")); } } } }