diff --git a/src/RoleEditor/App.config b/src/RoleEditor/App.config index 49cc43e..7c6ee29 100644 --- a/src/RoleEditor/App.config +++ b/src/RoleEditor/App.config @@ -1,3 +1,15 @@  + + +
+ + + + + + Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling;Port=33306 + + + \ No newline at end of file diff --git a/src/RoleEditor/MainWindow.xaml.cs b/src/RoleEditor/MainWindow.xaml.cs index 6bc1a6f..c3b4cef 100644 --- a/src/RoleEditor/MainWindow.xaml.cs +++ b/src/RoleEditor/MainWindow.xaml.cs @@ -49,11 +49,11 @@ namespace RoleEditor } private async void Window_Loaded(object sender, RoutedEventArgs e) - { - - // try database connection + { try { + DBManager.SetConnectionString(Properties.Settings.Default.ConnectionString); + // load all participants List participants = await Participant.LoadAll(_dbManager); foreach(Participant p in participants) diff --git a/src/RoleEditor/Properties/Settings.Designer.cs b/src/RoleEditor/Properties/Settings.Designer.cs new file mode 100644 index 0000000..eab12af --- /dev/null +++ b/src/RoleEditor/Properties/Settings.Designer.cs @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace RoleEditor.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling;" + + "Port=33306")] + public string ConnectionString { + get { + return ((string)(this["ConnectionString"])); + } + } + } +} diff --git a/src/RoleEditor/Properties/Settings.settings b/src/RoleEditor/Properties/Settings.settings new file mode 100644 index 0000000..497dc89 --- /dev/null +++ b/src/RoleEditor/Properties/Settings.settings @@ -0,0 +1,9 @@ + + + + + + Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling;Port=33306 + + + \ No newline at end of file diff --git a/src/RoleEditor/RoleEditor.csproj b/src/RoleEditor/RoleEditor.csproj index a158f56..58869d9 100644 --- a/src/RoleEditor/RoleEditor.csproj +++ b/src/RoleEditor/RoleEditor.csproj @@ -60,6 +60,11 @@ + + True + True + Settings.settings + True True @@ -74,4 +79,11 @@ + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + diff --git a/src/brecal.mysql/DBManager.cs b/src/brecal.mysql/DBManager.cs index 9e589a3..d5c5571 100644 --- a/src/brecal.mysql/DBManager.cs +++ b/src/brecal.mysql/DBManager.cs @@ -1,15 +1,19 @@ using brecal.model; using MySqlConnector; using System.Data; -using System.Runtime.CompilerServices; using static brecal.model.IDBManager; namespace brecal.mysql { public class DBManager : IDBManager { - // TODO: remove this and use external configuration - private static readonly string _connectionString = "Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling;Port=33306"; + + private static string _connectionString = ""; + + public static void SetConnectionString(string connectionString) + { + _connectionString = connectionString; + } public async Task> Load(QueryFunc prepareAction, LoadFunc loadAction, params object?[] args) {