From dbea367027d809f130e007caebd50f611d68474c Mon Sep 17 00:00:00 2001 From: emkael Date: Sat, 30 Sep 2017 20:10:45 +0200 Subject: On BWS convert, fill Settings table with records for separate sections --- Aktywator/Bws.cs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'Aktywator') diff --git a/Aktywator/Bws.cs b/Aktywator/Bws.cs index 05fcb83..fd24418 100644 --- a/Aktywator/Bws.cs +++ b/Aktywator/Bws.cs @@ -351,6 +351,8 @@ namespace Aktywator s.createField(sql); } + this.convertSettingsPerSection(); + try { sql.query("ALTER TABLE Tables ADD COLUMN `Group` integer;"); @@ -416,6 +418,37 @@ namespace Aktywator } } + private void convertSettingsPerSection() + { + string sectionString = this.getSections(); + string[] sections = sectionString.Split(','); + OleDbDataReader defaultSettings = sql.select("SELECT * FROM `Settings`"); + if (defaultSettings.Read()) + { + object[] values = new object[100]; + int columns = defaultSettings.GetValues(values); + Dictionary objects = new Dictionary(); + for (int i = 0; i < columns; i++) + { + objects.Add(defaultSettings.GetName(i), values[i]); + } + defaultSettings.Close(); + foreach (string section in sections) + { + try + { + string sectionData = sql.selectOne("SELECT `Section` FROM `Settings` WHERE `Section` = " + section, true); + } + catch (OleDbRowMissingException e) + { + objects["Section"] = section; + sql.insert("Settings", objects); + } + } + sql.query("DELETE FROM `Settings` WHERE `Section` NOT IN (" + sectionString + ")"); + } + } + public void updateSettings() { sql.query("UPDATE Tables SET UpdateFromRound=997;"); @@ -426,6 +459,7 @@ namespace Aktywator main.startLoading(); if (settings == null) { + main.stopLoading(); return; } main.lFirstSectorSettings.Visible = false; -- cgit v1.2.3