/// <summary>
        /// Performs validation over the given input parameters. Error and status information is logged
        /// during the execution of the operation.
        /// </summary>
        /// <param name="waveConditionsInput">The input of the calculation.</param>
        /// <param name="assessmentLevel">The assessment level to use for determining water levels.</param>
        /// <param name="hydraulicBoundaryDatabase">The hydraulic boundary database to validate.</param>
        /// <returns><c>true</c> if there were no validation errors; <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="waveConditionsInput"/> or
        /// <paramref name="hydraulicBoundaryDatabase"/> is <c>null</c>.</exception>
        public static bool Validate(WaveConditionsInput waveConditionsInput,
                                    RoundedDouble assessmentLevel,
                                    HydraulicBoundaryDatabase hydraulicBoundaryDatabase)
        {
            if (waveConditionsInput == null)
            {
                throw new ArgumentNullException(nameof(waveConditionsInput));
            }

            if (hydraulicBoundaryDatabase == null)
            {
                throw new ArgumentNullException(nameof(hydraulicBoundaryDatabase));
            }

            CalculationServiceHelper.LogValidationBegin();

            string[] messages = ValidateInput(hydraulicBoundaryDatabase,
                                              waveConditionsInput,
                                              assessmentLevel);

            CalculationServiceHelper.LogMessagesAsError(messages);

            CalculationServiceHelper.LogValidationEnd();

            return(!messages.Any());
        }
        /// <summary>
        /// Performs validation over the values on the given <paramref name="calculation"/>. Error and status information is logged during
        /// the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="ProbabilisticPipingCalculation"/> for which to validate the values.</param>
        /// <param name="failureMechanism">The <see cref="PipingFailureMechanism"/> for which to validate the values.</param>
        /// <param name="assessmentSection">The <see cref="IAssessmentSection"/> for which to validate the values.</param>
        /// <returns><c>true</c> if <paramref name="calculation"/> has no validation errors; <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static bool Validate(ProbabilisticPipingCalculation calculation,
                                    PipingFailureMechanism failureMechanism,
                                    IAssessmentSection assessmentSection)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (failureMechanism == null)
            {
                throw new ArgumentNullException(nameof(failureMechanism));
            }

            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            CalculationServiceHelper.LogValidationBegin();

            LogAnyWarnings(calculation);

            bool hasErrors = LogAnyErrors(calculation, failureMechanism, assessmentSection);

            CalculationServiceHelper.LogValidationEnd();

            return(!hasErrors);
        }
        /// <summary>
        /// Performs validation over the values on the given <paramref name="calculation"/>. Error and status information is logged during
        /// the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="GrassCoverErosionInwardsCalculation"/> for which to validate the values.</param>
        /// <param name="assessmentSection">The <see cref="IAssessmentSection"/> for which to validate the values.</param>
        /// <returns><c>true</c> if <paramref name="calculation"/> has no validation errors; <c>false</c> otherwise.</returns>
        public static bool Validate(GrassCoverErosionInwardsCalculation calculation, IAssessmentSection assessmentSection)
        {
            CalculationServiceHelper.LogValidationBegin();

            string[] hydraulicBoundaryDatabaseMessages = ValidateHydraulicBoundaryDatabase(assessmentSection).ToArray();
            CalculationServiceHelper.LogMessagesAsError(hydraulicBoundaryDatabaseMessages);
            if (hydraulicBoundaryDatabaseMessages.Any())
            {
                CalculationServiceHelper.LogValidationEnd();
                return(false);
            }

            string[] messages = ValidateInput(calculation.InputParameters).ToArray();
            CalculationServiceHelper.LogMessagesAsError(messages);
            CalculationServiceHelper.LogValidationEnd();
            return(!messages.Any());
        }
Esempio n. 4
0
        /// <summary>
        /// Performs validation over the values on the given <paramref name="calculation"/>. Error and status information is logged during
        /// the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="StructuresCalculation{T}"/> for which to validate the values.</param>
        /// <param name="assessmentSection">The <see cref="IAssessmentSection"/> for which to validate the values.</param>
        /// <returns><c>true</c> if <paramref name="calculation"/> has no validation errors; <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <exception cref="InvalidEnumArgumentException">Thrown when an invalid enum value is encountered.</exception>
        /// <exception cref="NotSupportedException">Thrown when an unsupported enum value is encountered.</exception>
        public static bool Validate(StructuresCalculation <TStructureInput> calculation, IAssessmentSection assessmentSection)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            CalculationServiceHelper.LogValidationBegin();
            string[] messages = ValidateInput(calculation.InputParameters, assessmentSection);
            CalculationServiceHelper.LogMessagesAsError(messages);
            CalculationServiceHelper.LogValidationEnd();

            return(!messages.Any());
        }
        /// <summary>
        /// Performs validation over the values on the given <paramref name="calculation"/>. Error and status information is logged during
        /// the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="SemiProbabilisticPipingCalculation"/> for which to validate the values.</param>
        /// <param name="generalInput">The <see cref="GeneralPipingInput"/> to derive values from during the validation.</param>
        /// <param name="normativeAssessmentLevel">The normative assessment level to use in case the manual assessment level is not applicable.</param>
        /// <returns><c>false</c> if <paramref name="calculation"/> contains validation errors; <c>true</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculation"/> or <paramref name="generalInput"/> is <c>null</c>.</exception>
        public static bool Validate(SemiProbabilisticPipingCalculation calculation,
                                    GeneralPipingInput generalInput,
                                    RoundedDouble normativeAssessmentLevel)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            CalculationServiceHelper.LogValidationBegin();

            LogAnyWarnings(calculation);

            bool hasErrors = LogAnyErrors(calculation, generalInput, normativeAssessmentLevel);

            CalculationServiceHelper.LogValidationEnd();

            return(!hasErrors);
        }
Esempio n. 6
0
        /// <summary>
        /// Performs validation over the values on the given <paramref name="calculation"/>. Error and status information is logged during
        /// the execution of the operation.
        /// </summary>
        /// <param name="calculation">The <see cref="MacroStabilityInwardsCalculation"/> for which to validate the values.</param>
        /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param>
        /// <param name="normativeAssessmentLevel">The normative assessment level to use in case the manual assessment level is not applicable.</param>
        /// <returns><c>false</c> if <paramref name="calculation"/> contains validation errors; <c>true</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public static bool Validate(MacroStabilityInwardsCalculation calculation, GeneralMacroStabilityInwardsInput generalInput, RoundedDouble normativeAssessmentLevel)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            CalculationServiceHelper.LogValidationBegin();

            string[] inputValidationResults = MacroStabilityInwardsInputValidator.Validate(calculation.InputParameters, normativeAssessmentLevel).ToArray();

            if (inputValidationResults.Length > 0)
            {
                CalculationServiceHelper.LogMessagesAsError(inputValidationResults);
                CalculationServiceHelper.LogValidationEnd();

                return(false);
            }

            IEnumerable <MacroStabilityInwardsKernelMessage> waternetExtremeKernelMessages;
            IEnumerable <MacroStabilityInwardsKernelMessage> waternetDailyKernelMessages;

            try
            {
                waternetExtremeKernelMessages = ValidateWaternet(() => WaternetCalculationService.ValidateExtreme(
                                                                     calculation.InputParameters, generalInput, GetEffectiveAssessmentLevel(calculation.InputParameters, normativeAssessmentLevel)),
                                                                 Resources.MacroStabilityInwardsCalculationService_Validate_Waternet_extreme_validation_started);
                waternetDailyKernelMessages = ValidateWaternet(() => WaternetCalculationService.ValidateDaily(calculation.InputParameters, generalInput),
                                                               Resources.MacroStabilityInwardsCalculationService_Validate_Waternet_daily_validation_started);
            }
            catch (WaternetCalculationException e)
            {
                HandleExceptionOnValidation(e);

                return(false);
            }

            IEnumerable <MacroStabilityInwardsKernelMessage> kernelMessages = Enumerable.Empty <MacroStabilityInwardsKernelMessage>();

            if (!waternetExtremeKernelMessages.Any() && !waternetDailyKernelMessages.Any())
            {
                IUpliftVanCalculator calculator = GetCalculator(calculation, generalInput, normativeAssessmentLevel);

                try
                {
                    kernelMessages = calculator.Validate().ToArray();
                }
                catch (UpliftVanCalculatorException e)
                {
                    HandleExceptionOnValidation(e);

                    return(false);
                }

                LogKernelMessages(kernelMessages);
            }

            CalculationServiceHelper.LogValidationEnd();

            return(kernelMessages.Concat(waternetDailyKernelMessages)
                   .Concat(waternetExtremeKernelMessages)
                   .All(r => r.Type != MacroStabilityInwardsKernelMessageType.Error));
        }
Esempio n. 7
0
 private static void HandleExceptionOnValidation(Exception e)
 {
     CalculationServiceHelper.LogExceptionAsError(Resources.MacroStabilityInwardsCalculationService_Validate_Error_in_MacroStabilityInwards_validation, e);
     CalculationServiceHelper.LogValidationEnd();
 }