Index: DamClients/DamUI/trunk/src/Dam/Forms/DamPlugin.cs =================================================================== diff -u -r6779 -r6797 --- DamClients/DamUI/trunk/src/Dam/Forms/DamPlugin.cs (.../DamPlugin.cs) (revision 6779) +++ DamClients/DamUI/trunk/src/Dam/Forms/DamPlugin.cs (.../DamPlugin.cs) (revision 6797) @@ -61,6 +61,7 @@ using DevExpress.XtraTreeList.Nodes; using ConversionHelper = Deltares.Dam.Data.DamEngineIo.ConversionHelper; using Location = Deltares.Dam.Data.Location; +using Message = Deltares.DamEngine.Io.XmlOutput.Message; using ProgressDelegate = Deltares.DamEngine.Data.Standard.Calculation.ProgressDelegate; using Sensor = Deltares.Dam.Data.Sensors.Sensor; using SensorLocation = Deltares.Dam.Data.Sensors.SensorLocation; @@ -224,7 +225,7 @@ // This is to force the version type (Alpha, Pre-Alpha etc.) to be updated mainForm.ReloadManager.ApplyCurrentUiCultureToAll(); // Set number of cores to 1 when multicore is not allowed - MaxCalculationCores = mainForm.AllowMultiCoreSelection ? MaxCalculationCores: 1; + MaxCalculationCores = mainForm.AllowMultiCoreSelection ? MaxCalculationCores : 1; mainForm.ProgramSettings.AllowMultiCoreSelection = mainForm.AllowMultiCoreSelection; } @@ -676,48 +677,45 @@ var damEngineInterface = new EngineInterface(localInput); damEngineInterface.ProgressDelegate = progressDelegate; string validationMessages = damEngineInterface.Validate(); - - // now the validation messages should be deserialized. If any, they should be passed on to the Validator - // and checked for errors. IF errors are found, then no calculation. When no messages or only warnings then - // do calculate. For now, just check length - if (string.IsNullOrEmpty(validationMessages)) + if (!string.IsNullOrEmpty(validationMessages)) { - if (!mainForm.AllowMultiCoreSelection) - { - // Multicore calculation not enabled - ThrowHelper.ThrowWhenConditionIsTrue(LocalizationManager.GetTranslatedText(this, "MultiCoreNotSupported"), - () => damEngineInterface.DamProjectData.MaxCalculationCores > 1); - - } - - // only if validation is ok, then - string outputXml = damEngineInterface.Run(); - Output output = DamXmlSerialization.LoadOutputFromXmlString(outputXml); - FillDamUiFromXmlOutput.AddOutputToDamProjectData(damProject.DamProjectData, output); - elapsedTime = DateTime.Now - startTimeCalculation; - timeMessage = String.Format(LocalizationManager.GetTranslatedText(this, "CalculationTime"), elapsedTime.ToString(@"dd\.hh\:mm\:ss")); - LocalizedMessageBox.ShowTranslatedText(mainForm, openingMessage + paragraphSepatator + timeMessage); -#if DEBUG - const string outputFilename = "OutputFile.xml"; - DamXmlSerialization.SaveOutputAsXmlFile(outputFilename, output); -#endif - } - else - { + // The validation messages are deserialized. They are passed to the LogManager. Output outputValidation = DamXmlSerialization.LoadOutputFromXmlString(validationMessages); - foreach (var validationResult in outputValidation.ValidationResults) + foreach (Message validationResult in outputValidation.ValidationResults) { LogManager.Add(new LogMessage(ConversionHelper.ConvertToMessageType(validationResult.MessageType), typeof(EngineInterface), validationResult.Message1)); } - foreach (var calculationMessage in outputValidation.Results.CalculationMessages) + + foreach (Message calculationMessage in outputValidation.Results.CalculationMessages) { LogManager.Add(new LogMessage(ConversionHelper.ConvertToMessageType(calculationMessage.MessageType), typeof(EngineInterface), calculationMessage.Message1)); } + + // If there are errors found throw an expection to stop calculation. if (LogManager.Messages.Any(m => m.MessageType == LogMessageType.Error)) { throw new Exception(LocalizationManager.GetTranslatedText(this, "ValidationErrorsOccurred")); } } + + // There are no errors, so perform calculation. + if (!mainForm.AllowMultiCoreSelection) + { + // Multicore calculation not enabled + ThrowHelper.ThrowWhenConditionIsTrue(LocalizationManager.GetTranslatedText(this, "MultiCoreNotSupported"), + () => damEngineInterface.DamProjectData.MaxCalculationCores > 1); + } + + string outputXml = damEngineInterface.Run(); + Output output = DamXmlSerialization.LoadOutputFromXmlString(outputXml); + FillDamUiFromXmlOutput.AddOutputToDamProjectData(damProject.DamProjectData, output); + elapsedTime = DateTime.Now - startTimeCalculation; + timeMessage = String.Format(LocalizationManager.GetTranslatedText(this, "CalculationTime"), elapsedTime.ToString(@"dd\.hh\:mm\:ss")); + LocalizedMessageBox.ShowTranslatedText(mainForm, openingMessage + paragraphSepatator + timeMessage); +#if DEBUG + const string outputFilename = "OutputFile.xml"; + DamXmlSerialization.SaveOutputAsXmlFile(outputFilename, output); +#endif } catch (Exception e) { @@ -740,6 +738,7 @@ LogManager.Messages.AddRange(damProject.DamProjectData.CalculationMessages); mainForm.Invoke(new PublisherDelegate(DataEventPublisher.DataListModified), LogManager.Messages, null); } + SetProperControlsAfterDesignCalculation(); } @@ -1066,7 +1065,7 @@ private void Import() { LogManager.Clear(); - + damProject.DamProjectData.WaterBoard.SelectedDike = new Dike(); mainForm.Invoke(new TaskDelegate(DataEventPublisher.SelectionChanged), damProject.DamProjectData.WaterBoard.SelectedDike);