Datenbank ausgelagert, außerhalb des Ordners
This commit is contained in:
@@ -16,7 +16,7 @@ namespace Database
|
||||
{
|
||||
public class Datenbank
|
||||
{
|
||||
public const string pfad = "./";
|
||||
public string pfad;
|
||||
public string projekt;
|
||||
public static readonly Datenbank instance = new Datenbank();
|
||||
public static Datenbank Instance
|
||||
@@ -27,18 +27,27 @@ namespace Database
|
||||
}
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
TeufelDB = new KlassenBIB.DB();
|
||||
string filepath = "";
|
||||
filepath = Path.Combine(pfad, "projekte", "TeufelDB.xaml");
|
||||
|
||||
if(!Directory.Exists(Path.Combine(pfad,"projekte")))
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(pfad, "projekte"));
|
||||
return;
|
||||
}
|
||||
if (File.Exists(filepath))
|
||||
TeufelDB = XamlServices.Load(filepath) as KlassenBIB.DB;
|
||||
}
|
||||
|
||||
public KlassenBIB.Projekt loadedProjekt = null;
|
||||
//public KlassenBIB.MainDataBase MainDatenbank = null;
|
||||
public KlassenBIB.DB TeufelDB = null;
|
||||
|
||||
public Datenbank()
|
||||
{
|
||||
TeufelDB = new KlassenBIB.DB();
|
||||
string filepath = "";
|
||||
filepath = Path.Combine("./projekte", "TeufelDB.xaml");
|
||||
if(File.Exists(filepath))
|
||||
TeufelDB = XamlServices.Load("./projekte/TeufelDB.xaml") as KlassenBIB.DB;
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +57,8 @@ namespace Database
|
||||
this.projekt = projekt;
|
||||
loadedProjekt = Datenbank.Instance.TeufelDB.Projekte.Find(x => x.Nummer != null && x.Nummer.Equals(projekt));
|
||||
|
||||
if (!File.Exists("./projekte/TeufelDB.xaml"))
|
||||
string filepath = Path.Combine(pfad, "projekte", "TeufelDB.xaml");
|
||||
if (!File.Exists(filepath))
|
||||
{
|
||||
UpdateDatabase.UpdateNewGuids();
|
||||
|
||||
@@ -72,7 +82,9 @@ namespace Database
|
||||
|
||||
public void SaveProjekt()
|
||||
{
|
||||
XamlServices.Save("./projekte/TeufelDB.xaml", TeufelDB);
|
||||
string filepath = Path.Combine(pfad, "projekte", "TeufelDB.xaml");
|
||||
Trace.WriteLine(filepath);
|
||||
XamlServices.Save(filepath, TeufelDB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user