// Copyright (C) Stichting Deltares 2025. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System.Collections.Generic; using Deltares.DamEngine.Io.XmlOutput; using Deltares.Standard.Logging; namespace Deltares.Dam.Data.DamEngineIo; /// /// /// public class FillXmlOutputFromDamUi { /// /// Class to fill the output xml based on the results in DamProjectData /// public static Output CreateOutput(DamProjectData damProjectData) { var output = new Output(); output.Results = new OutputResults(); output.Results.CalculationMessages = new Message[damProjectData.CalculationMessages.Count]; TransferOutputCalculationMessages(damProjectData.CalculationMessages, output.Results); if (damProjectData.DesignCalculations != null && damProjectData.DesignCalculations.Count > 0) { output.Results.CalculationResults = new DesignResult[damProjectData.DesignCalculations.Count]; for (var i = 0; i < damProjectData.DesignCalculations.Count; i++) { var designResult = new DesignResult(); designResult.CalculationSubDir = damProjectData.DesignCalculations[i].CalculationSubDir; designResult.LocationName = damProjectData.DesignCalculations[i].LocationName; designResult.BaseFileName = damProjectData.DesignCalculations[i].BaseFileName; designResult.ScenarioName = damProjectData.DesignCalculations[i].ScenarioName; designResult.StabilityDesignResults = new DesignResultStabilityDesignResults(); output.Results.CalculationResults[i] = designResult; } } return output; } private static void TransferOutputCalculationMessages(List calculationMessages, OutputResults outputResults) { //var calculationMessages = damProjectData.CalculationMessages; if (calculationMessages != null) { outputResults.CalculationMessages = new Message[calculationMessages.Count]; for (var i = 0; i < calculationMessages.Count; i++) { var message = new Message(); message.MessageType = ConversionHelper.ConvertToInputMessageType(calculationMessages[i].MessageType); message.Message1 = calculationMessages[i].Message; outputResults.CalculationMessages[i] = message; } } } }