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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
@@ -19,4 +24,11 @@
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<userSettings>
|
||||
<SanSystem.Properties.Settings>
|
||||
<setting name="DATABASEMAIN" serializeAs="String">
|
||||
<value>C:\</value>
|
||||
</setting>
|
||||
</SanSystem.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace SanSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(speicherpfad_to_projekts, projektpfad);
|
||||
return Path.Combine(Properties.Settings.Default.DATABASEMAIN,speicherpfad_to_projekts, projektpfad);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
[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'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="SanSystem.Properties" GeneratedClassName="Settings">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="DATABASEMAIN" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)">C:\</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@@ -30,8 +30,11 @@ namespace SanSystem
|
||||
public frmMain()
|
||||
{
|
||||
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);
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user