// Copyright (C) Stichting Deltares 2017. 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 System.Xml.Serialization; using Deltares.Standard; using Deltares.Standard.IO.Xml; using XmlSerializer = Deltares.Standard.IO.Xml.XmlSerializer; namespace Deltares.Dam.Data { public class EvaluationJob { private string dikeName = ""; private List locations = new List(); private List failedEvaluatedLocations = new List(); private List results = new List(); private List schematizationFactorResults = new List(); public string DikeName { get { return dikeName; } set { dikeName = value; } } public List Locations { get { return locations; } set { locations = value; } } public List Results { get { return results; } set { results = value; } } public List SchematizationFactorResults { get { return schematizationFactorResults; } set { schematizationFactorResults = value; } } [XmlIgnore] public string XML { get { XmlSerializer serializer = new XmlSerializer(); return serializer.SerializeToString(this); } set { XmlDeserializer deserializer = new XmlDeserializer(); EvaluationJob job = (EvaluationJob)deserializer.XmlDeserializeFromString(value, typeof(EvaluationJob)); this.DikeName = job.DikeName; this.Locations.Clear(); this.Locations.AddRange(job.Locations); this.Results.Clear(); this.Results.AddRange(job.Results); this.schematizationFactorResults.Clear(); this.schematizationFactorResults.AddRange(job.schematizationFactorResults); } } public List FailedEvaluatedLocations { get { return failedEvaluatedLocations; } set { failedEvaluatedLocations = value; } } public void AttachResults(IEnumerable locationJobs) { foreach (LocationJob locationJob in locationJobs) { foreach (Location location in this.locations) { if (locationJob.Location.Name.Equals(location.Name)) { if (locationJob.LocationResult == null) { locationJob.LocationResult = new LocationResult(); } if ((this.locations.IndexOf(location) < 0) || (this.locations.IndexOf(location) >= this.results.Count)) { var failedRes = new RWScenariosResult(); failedRes.CalculationResult = CalculationResult.UnexpectedError; locationJob.LocationResult.RWScenariosResult = failedRes; } else { locationJob.LocationResult.RWScenariosResult = this.results[this.locations.IndexOf(location)]; } foreach (RWScenarioResult scenarioResult in locationJob.LocationResult.RWScenariosResult.RWScenarioResults) { foreach (RWScenarioProfileResult scenarioProfileResult in scenarioResult.RWScenarioProfileResults) { scenarioProfileResult.Location = locationJob.Location; } } if ((this.locations.IndexOf(location) < 0) || (this.locations.IndexOf(location) >= this.results.Count)) { // var failedRes = new RWSchematizationFactorsResult(); // failedRes.SchematizationFactorResults. = CalculationResult.UnexpectedError; // locationJob.LocationResult.RWScenariosResult = failedRes; } else { if (schematizationFactorResults.Count > this.locations.IndexOf(location)) { locationJob.LocationResult.SchematizationFactorsResult = schematizationFactorResults[this.locations.IndexOf(location)]; } } if (locationJob.LocationResult.SchematizationFactorsResult != null) { foreach (var schematizationFactorResult in locationJob.LocationResult.SchematizationFactorsResult.SchematizationFactorResults) { schematizationFactorResult.Location = locationJob.Location; } } } } } } } }