Datenbank ausgelagert, außerhalb des Ordners
This commit is contained in:
@@ -16,7 +16,7 @@ namespace Database
|
|||||||
{
|
{
|
||||||
public class Datenbank
|
public class Datenbank
|
||||||
{
|
{
|
||||||
public const string pfad = "./";
|
public string pfad;
|
||||||
public string projekt;
|
public string projekt;
|
||||||
public static readonly Datenbank instance = new Datenbank();
|
public static readonly Datenbank instance = new Datenbank();
|
||||||
public static Datenbank Instance
|
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.Projekt loadedProjekt = null;
|
||||||
//public KlassenBIB.MainDataBase MainDatenbank = null;
|
//public KlassenBIB.MainDataBase MainDatenbank = null;
|
||||||
public KlassenBIB.DB TeufelDB = null;
|
public KlassenBIB.DB TeufelDB = null;
|
||||||
|
|
||||||
public Datenbank()
|
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;
|
this.projekt = projekt;
|
||||||
loadedProjekt = Datenbank.Instance.TeufelDB.Projekte.Find(x => x.Nummer != null && x.Nummer.Equals(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();
|
UpdateDatabase.UpdateNewGuids();
|
||||||
|
|
||||||
@@ -72,7 +82,9 @@ namespace Database
|
|||||||
|
|
||||||
public void SaveProjekt()
|
public void SaveProjekt()
|
||||||
{
|
{
|
||||||
XamlServices.Save("./projekte/TeufelDB.xaml", TeufelDB);
|
string filepath = Path.Combine(pfad, "projekte", "TeufelDB.xaml");
|
||||||
|
Trace.WriteLine(filepath);
|
||||||
|
XamlServices.Save(filepath, TeufelDB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<configSections>
|
||||||
|
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
|
||||||
|
<section name="SanSystem.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||||
|
</sectionGroup>
|
||||||
|
</configSections>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||||
</startup>
|
</startup>
|
||||||
@@ -19,4 +24,11 @@
|
|||||||
</dependentAssembly>
|
</dependentAssembly>
|
||||||
</assemblyBinding>
|
</assemblyBinding>
|
||||||
</runtime>
|
</runtime>
|
||||||
|
<userSettings>
|
||||||
|
<SanSystem.Properties.Settings>
|
||||||
|
<setting name="DATABASEMAIN" serializeAs="String">
|
||||||
|
<value>C:\</value>
|
||||||
|
</setting>
|
||||||
|
</SanSystem.Properties.Settings>
|
||||||
|
</userSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace SanSystem
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Path.Combine(speicherpfad_to_projekts, projektpfad);
|
return Path.Combine(Properties.Settings.Default.DATABASEMAIN,speicherpfad_to_projekts, projektpfad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ILanguage language = null;
|
public ILanguage language = null;
|
||||||
|
|||||||
12
SanSystem/Properties/Settings.Designer.cs
generated
12
SanSystem/Properties/Settings.Designer.cs
generated
@@ -22,5 +22,17 @@ namespace SanSystem.Properties {
|
|||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("C:\\")]
|
||||||
|
public string DATABASEMAIN {
|
||||||
|
get {
|
||||||
|
return ((string)(this["DATABASEMAIN"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["DATABASEMAIN"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SanSystem.Properties" GeneratedClassName="Settings">
|
||||||
<Profiles>
|
<Profiles />
|
||||||
<Profile Name="(Default)" />
|
<Settings>
|
||||||
</Profiles>
|
<Setting Name="DATABASEMAIN" Type="System.String" Scope="User">
|
||||||
<Settings />
|
<Value Profile="(Default)">C:\</Value>
|
||||||
</SettingsFile>
|
</Setting>
|
||||||
|
</Settings>
|
||||||
|
</SettingsFile>
|
||||||
@@ -30,8 +30,11 @@ namespace SanSystem
|
|||||||
public frmMain()
|
public frmMain()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
string sx = Properties.Settings.Default.DATABASEMAIN;
|
||||||
|
|
||||||
|
|
||||||
|
Datenbank.Instance.pfad = sx;
|
||||||
|
Datenbank.Instance.Init();
|
||||||
if (!Directory.Exists(Global.Instance.Projektpfad)) Directory.CreateDirectory(Global.Instance.Projektpfad);
|
if (!Directory.Exists(Global.Instance.Projektpfad)) Directory.CreateDirectory(Global.Instance.Projektpfad);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user