Es wird überprüft auf den Datenbank version

This commit is contained in:
Husky
2018-08-12 11:15:31 +02:00
parent e14f251a69
commit 28141470da
5 changed files with 54 additions and 3 deletions

View File

@@ -53,6 +53,10 @@
<Project>{c82bd650-466b-403f-bed9-2b1660771f54}</Project>
<Name>KlassenBIB</Name>
</ProjectReference>
<ProjectReference Include="..\SanShared\SanShared.csproj">
<Project>{c949087e-20e1-4a17-b021-faead363c1d8}</Project>
<Name>SanShared</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View File

@@ -10,6 +10,7 @@ using System.Diagnostics;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.Core;
using KlassenBIB;
using SanShared.Exceptions;
namespace Database
{
@@ -40,7 +41,16 @@ namespace Database
if (File.Exists(filepath))
{
File.Copy(filepath, string.Format("{0}_{1}_{2}.bak", filepath,DateTime.Now.ToShortDateString(),DateTime.Now.Ticks));
loadedProjekt = XamlServices.Load(filepath) as KlassenBIB.Projekt;
try
{
loadedProjekt = XamlServices.Load(filepath) as KlassenBIB.Projekt;
}
catch(XamlObjectWriterException ex)
{
string msg = ex.Message;
if (msg.ToLower().Contains("kann nicht festgelegt werden"))
throw new DataBaseVersionMismatchException();
}
}
else
loadedProjekt = new KlassenBIB.Projekt();

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace SanShared.Exceptions
{
public class DataBaseVersionMismatchException : Exception
{
public DataBaseVersionMismatchException()
{
}
public DataBaseVersionMismatchException(string message) : base(message)
{
}
public DataBaseVersionMismatchException(string message, Exception innerException) : base(message, innerException)
{
}
protected DataBaseVersionMismatchException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}

View File

@@ -42,6 +42,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BilderObject.cs" />
<Compile Include="Exceptions\DataBaseVersionMismatchException.cs" />
<Compile Include="Exceptions\LangNotFoundException.cs" />
<Compile Include="IAuftraggeber.cs" />
<Compile Include="ILanguage.cs" />

View File

@@ -1,6 +1,7 @@
using Database;
using FluentFTP;
using KlassenBIB;
using SanShared.Exceptions;
using SchnittstelleImporter;
using System;
using System.Collections.Generic;
@@ -31,8 +32,15 @@ namespace SanSystem
//Global.Instance.
if (!Directory.Exists(Global.Instance.Projektpfad)) Directory.CreateDirectory(Global.Instance.Projektpfad);
Datenbank.Instance.LoadProjekt(Global.Instance.ProjektNummer, Global.Instance.Projektpfad);// Path.Combine(Global.Instance.Projektpfad,"18-850.xaml"));
try
{
Datenbank.Instance.LoadProjekt(Global.Instance.ProjektNummer, Global.Instance.Projektpfad);// Path.Combine(Global.Instance.Projektpfad,"18-850.xaml"));
}
catch(DataBaseVersionMismatchException)
{
MessageBox.Show("Database version mistmatch\nProgramm wird beendet");
Environment.Exit(0);
}
//Datenbank.Instance.CreateProjekt("");
this.Width = Screen.PrimaryScreen.WorkingArea.Width;