Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs =================================================================== diff -u -r0a51f20ac93373a43f79bb4c6327bce1d46545c6 -r49d90fb457184cd520ada77ee07774405985abd5 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision 0a51f20ac93373a43f79bb4c6327bce1d46545c6) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision 49d90fb457184cd520ada77ee07774405985abd5) @@ -20,7 +20,6 @@ // All rights reserved. using System.Collections.Generic; -using log4net; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Probabilistics; @@ -40,8 +39,6 @@ /// internal static class HeightStructuresCalculationService { - private static readonly ILog heightStructuresCalculationLogger = LogManager.GetLogger(typeof(HeightStructuresCalculationService)); - /// /// Performs validation over the values on the given . Error and status information is logged during /// the execution of the operation. @@ -51,19 +48,7 @@ /// False if contains validation errors; True otherwise. internal static bool Validate(HeightStructuresCalculation calculation, IAssessmentSection assessmentSection) { - heightStructuresCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Validation_Subject_0_started_Time_1_, - calculation.Name, DateTimeService.CurrentTimeAsString)); - - var inputValidationResults = ValidateInput(calculation.InputParameters, assessmentSection); - - if (inputValidationResults.Count > 0) - { - LogMessagesAsError(RingtoetsCommonServiceResources.Error_in_validation_0, inputValidationResults.ToArray()); - } - - LogValidationEndTime(calculation); - - return inputValidationResults.Count == 0; + return CalculationServiceHelper.PerformValidation(calculation.Name, () => ValidateInput(calculation.InputParameters, assessmentSection)); } /// @@ -80,26 +65,10 @@ string hlcdDirectory, FailureMechanismSection failureMechanismSection, string ringId, GeneralHeightStructuresInput generalInput) { - heightStructuresCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Calculation_Subject_0_started_Time_1_, - calculation.Name, DateTimeService.CurrentTimeAsString)); - - try - { - var input = CreateInput(calculation, failureMechanismSection, generalInput); - var output = HydraRingCalculationService.PerformCalculation(hlcdDirectory, ringId, HydraRingTimeIntegrationSchemeType.FBC, HydraRingUncertaintiesType.All, input); - - if (output == null) - { - LogMessagesAsError(Resources.HeightStructuresCalculationService_Calculate_Error_in_height_structures_0_calculation, calculation.Name); - } - - return output; - } - finally - { - heightStructuresCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Calculation_Subject_0_ended_Time_1_, - calculation.Name, DateTimeService.CurrentTimeAsString)); - } + var input = CreateInput(calculation, failureMechanismSection, generalInput); + return CalculationServiceHelper.PerformCalculation(calculation.Name, + () => HydraRingCalculationService.PerformCalculation(hlcdDirectory, ringId, HydraRingTimeIntegrationSchemeType.FBC, HydraRingUncertaintiesType.All, input), + Resources.HeightStructuresCalculationService_Calculate_Error_in_height_structures_0_calculation); } private static StructuresOvertoppingCalculationInput CreateInput(HeightStructuresCalculation calculation, FailureMechanismSection failureMechanismSection, GeneralHeightStructuresInput generalInput) @@ -142,19 +111,5 @@ return validationResult; } - - private static void LogMessagesAsError(string format, params string[] errorMessages) - { - foreach (var errorMessage in errorMessages) - { - heightStructuresCalculationLogger.ErrorFormat(format, errorMessage); - } - } - - private static void LogValidationEndTime(HeightStructuresCalculation calculation) - { - heightStructuresCalculationLogger.Info(string.Format(RingtoetsCommonServiceResources.Validation_Subject_0_ended_Time_1_, - calculation.Name, DateTimeService.CurrentTimeAsString)); - } } } \ No newline at end of file