Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamProject.cs
===================================================================
diff -u -r2529 -r2864
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamProject.cs (.../DamProject.cs) (revision 2529)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamProject.cs (.../DamProject.cs) (revision 2864)
@@ -29,6 +29,7 @@
using Deltares.Standard.IO.DtoAssembler;
using Deltares.Standard.Reflection;
using System.IO;
+using System.Xml;
using Deltares.Dam.Data.IO;
using Deltares.Geotechnics.Soils;
using Deltares.Standard;
@@ -58,7 +59,7 @@
public DamProject()
{
- this.damProjectData = new DamProjectData();
+ this.damProjectData = new DamProjectData();
}
public static string GetNewTempDirectory()
@@ -272,6 +273,10 @@
object project = xmlSerializer.XmlDeserialize(fileName, typeof(DamProjectData), new DefaultClassFactory());
this.damProjectData = (DamProjectData)project;
+ if (damProjectData != null)
+ {
+ damProjectData.VersionInfo.InitVersionInfoAfterRead();
+ }
if (damProjectData.DamProjectType == DamProjectType.AssessOld)
{
ClearProject();
@@ -297,6 +302,7 @@
}
// Project still needs a reference to soilmaterials database; to be resolved later.
// This will become obsolete as soon as Delphi DGeoStability version is no longer used.
+ ResolveBackwardCompatibility();
UpdateSoilDatabaseReferences(damProjectFolder);
UpdateSoilPropertiesToSoilDatabase();
});
@@ -310,6 +316,15 @@
return damProjectData;
}
+ private void ResolveBackwardCompatibility()
+ {
+ if (DamProjectData.VersionInfo.FileVersionAsRead == 0)
+ {
+ XmlDocument xmlDocument = new XmlDocument();
+ xmlDocument.LoadXml(this.ProjectFileName);
+ }
+ }
+
///
/// Updates older projects for missing data or changed data model.
///
@@ -666,6 +681,8 @@
savedProjectMap = ProjectMap;
}
+ damProjectData.VersionInfo.InitVersionInfo();
+
DataEventPublisher.InvokeWithoutPublishingEvents(() =>
{
EnsureSoilmaterialsFileWithProject(fileName);
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Deltares.Dam.Data.csproj
===================================================================
diff -u -r2576 -r2864
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Deltares.Dam.Data.csproj (.../Deltares.Dam.Data.csproj) (revision 2576)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Deltares.Dam.Data.csproj (.../Deltares.Dam.Data.csproj) (revision 2864)
@@ -194,6 +194,7 @@
+
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamProjectData.cs
===================================================================
diff -u -r2508 -r2864
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamProjectData.cs (.../DamProjectData.cs) (revision 2508)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamProjectData.cs (.../DamProjectData.cs) (revision 2864)
@@ -25,6 +25,7 @@
using System.Linq;
using System.Xml.Serialization;
using System.Collections.Generic;
+using Deltares.Dam.Data.IO;
using Deltares.Dam.Data.Sensors;
using Deltares.Standard;
using Deltares.Standard.Attributes;
@@ -40,6 +41,7 @@
public class DamProjectData : Project, IDomain, IDisposable
{
public readonly double MissValStabilitySafetyFactor = -1.0;
+ private VersionInfo versionInfo;
private WaterBoard waterBoard;
private DamProjectCalculationSpecification damProjectCalculationSpecification;
private WaterBoardJob waterBoardJob = null;
@@ -59,11 +61,20 @@
///
public DamProjectData()
{
+ this.versionInfo = new VersionInfo();
this.waterBoard = new WaterBoard();
this.waterBoardJob = null;
this.damProjectCalculationSpecification = new DamProjectCalculationSpecification();
}
+ /// Gets the version information.
+ /// The version information.
+ public VersionInfo VersionInfo
+ {
+ get { return versionInfo; }
+ set { versionInfo = value; }
+ }
+
///
/// Gets or sets the project working path.
///
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/IO/VersionInfo.cs
===================================================================
diff -u
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/IO/VersionInfo.cs (revision 0)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/IO/VersionInfo.cs (revision 2864)
@@ -0,0 +1,87 @@
+// Copyright (C) Stichting Deltares 2019. All rights reserved.
+//
+// This file is part of the application DAM - Clients Library.
+//
+// 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.Reflection;
+using System.Xml.Serialization;
+using Deltares.Standard.Attributes;
+
+namespace Deltares.Dam.Data.IO
+{
+ [XmlNoKey]
+ public class VersionInfo
+ {
+ public const int CurrentFileVersion = 1;
+ /// Current File Version.
+ /// The file version.
+ ///
+ ///
+ public int FileVersion { get; set; } // Default is 0 and indicates the situation that FileVersion was not introduced yet
+
+ /// Gets or sets the assembly name with which the input file is being created.
+ /// The program version.
+ ///
+ public string AssemblyName { get; set; }
+
+ /// Gets or sets the assembly version with which the input file is being created.
+ /// The program version.
+ ///
+ public string AssemblyVersion { get; set; }
+
+ /// Gets or sets the version as read.
+ /// The file version as read.
+ ///
+ ///
+ [XmlIgnore]
+ public int FileVersionAsRead { get; set; }
+ /// Gets or sets the assembly name with which the input file has been created.
+ /// The assembly version as read.
+ [XmlIgnore]
+ public string AssemblyNameAsRead { get; set; }
+
+ /// Gets or sets the assembly version with which the input file has been created.
+ /// The assembly version as read.
+ [XmlIgnore]
+ public string AssemblyVersionAsRead { get; set; }
+
+ /// Initializes the version information to the current program version.
+ public void InitVersionInfo()
+ {
+ FileVersion = VersionInfo.CurrentFileVersion;
+ var hostAssembly = Assembly.GetEntryAssembly();
+ if (hostAssembly == null)
+ {
+ hostAssembly = Assembly.GetExecutingAssembly();
+ }
+ AssemblyName = hostAssembly.GetName().Name;
+ AssemblyVersion = hostAssembly.GetName().Version.ToString();
+ }
+
+ /// After the read the current version info should be transferred to the ..AsRead fields
+ /// and after that current version info can be initialized.
+ public void InitVersionInfoAfterRead()
+ {
+ FileVersionAsRead = FileVersion;
+ AssemblyNameAsRead = AssemblyName;
+ AssemblyVersionAsRead = AssemblyVersion;
+ InitVersionInfo();
+ }
+ }
+}
\ No newline at end of file