67 lines
2.0 KiB
C#
67 lines
2.0 KiB
C#
using KlassenBIB;
|
|
using SanShared;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xaml;
|
|
|
|
namespace Database
|
|
{
|
|
class UpdateDatabase
|
|
{
|
|
public static void UpdateNewGuids()
|
|
{
|
|
if (Datenbank.Instance.loadedProjekt == null) return;
|
|
foreach(var entries in Datenbank.Instance.loadedProjekt.Objekte)
|
|
{
|
|
|
|
if(entries.Guid.Equals(Guid.Empty))
|
|
entries.Guid = Guid.NewGuid();
|
|
|
|
|
|
foreach(var sanierungen in entries.Sanierung)
|
|
{
|
|
if (sanierungen.Guid.Equals(Guid.Empty))
|
|
sanierungen.Guid = Guid.NewGuid();
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
|
|
public static void TransferAuftraggeber()
|
|
{
|
|
List<string> projekte = new List<string>();
|
|
List<IAuftraggeber> auftraggebers = new List<IAuftraggeber>();
|
|
Projekt tempProjekt = null;
|
|
foreach(DirectoryInfo projekt in (new DirectoryInfo("./projekte").GetDirectories()))
|
|
{
|
|
projekte.Add(projekt.Name);
|
|
}
|
|
|
|
foreach(string t in projekte)
|
|
{
|
|
string filepath = Path.Combine("projekte", t, string.Format("{0}.xaml", t));
|
|
if (!File.Exists(filepath)) continue;
|
|
tempProjekt = XamlServices.Load(filepath) as KlassenBIB.Projekt;
|
|
|
|
//auftraggebers.Add(tempProjekt.Auftraggeber);
|
|
IAuftraggeber test = Datenbank.Instance.MainDatenbank.AuftraggeberListe.Find(x =>x.Name.Equals(tempProjekt.Auftraggeber.Name));
|
|
if (test != null)
|
|
{
|
|
|
|
continue;
|
|
}
|
|
|
|
Datenbank.Instance.MainDatenbank.AuftraggeberListe.Add(tempProjekt.Auftraggeber);
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|