From 530b93cfc05d014ffabbcdd70a067a0909adfe3a Mon Sep 17 00:00:00 2001 From: Udo Schlaepfer Date: Mon, 16 Apr 2018 10:25:44 +0200 Subject: [PATCH] Added missing economies. --- ED-IBE/Properties/AssemblyInfo.cs | 62 ++++++++-------- ED-IBE/Updater.cs | 73 ++++++++++++++++++- .../Database/script/create_Elite_DB.sql | 37 ++++++---- 3 files changed, 124 insertions(+), 48 deletions(-) diff --git a/ED-IBE/Properties/AssemblyInfo.cs b/ED-IBE/Properties/AssemblyInfo.cs index c211efb..4f8b720 100644 --- a/ED-IBE/Properties/AssemblyInfo.cs +++ b/ED-IBE/Properties/AssemblyInfo.cs @@ -1,36 +1,36 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("ED - Intelligent Boardcompter Extension")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] +[assembly: AssemblyTitle("ED - Intelligent Boardcompter Extension")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ED-IBE")] -[assembly: AssemblyCopyright("Copyright © 2016/17")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - +[assembly: AssemblyCopyright("Copyright © 2016/17")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4408F8B2-35C2-418D-9765-92FD85C35BE9")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: +[assembly: Guid("4408F8B2-35C2-418D-9765-92FD85C35BE9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.7.2.0")] -[assembly: AssemblyFileVersion("0.7.2.0")] +[assembly: AssemblyVersion("0.7.3.0")] +[assembly: AssemblyFileVersion("0.7.3.0")] diff --git a/ED-IBE/Updater.cs b/ED-IBE/Updater.cs index 63d7d69..f20795a 100644 --- a/ED-IBE/Updater.cs +++ b/ED-IBE/Updater.cs @@ -217,6 +217,8 @@ internal static void DBUpdate() if (dbVersion < new Version(0, 7, 2)) UpdateTo_0_7_2(ref foundError); + if (dbVersion < new Version(0, 7, 3)) + UpdateTo_0_7_3(ref foundError); if (!foundError) Program.DBCon.setIniValue("Database", "Version", appVersion.ToString()); @@ -247,7 +249,7 @@ internal static void DBUpdate() } } -#region update functions DB + #region update functions DB private static void UpdateTo_0_1_1(Version appVersion, ref Boolean foundError) { @@ -2165,6 +2167,75 @@ private static void UpdateTo_0_7_2(ref Boolean foundError) } } + + private static void UpdateTo_0_7_3(ref Boolean foundError) + { + try + { + String sqlString; + + Program.SplashScreen.InfoAdd("...updating structure of database to v0.7.3..."); + Program.SplashScreen.InfoAdd("...please be patient, this can take a few minutes depending on your system and data..."); + Program.SplashScreen.InfoAdd("..."); + + + sqlString = "INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (11, 'Repair'); \n" + + "INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (12, 'Rescue'); \n" + + "INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (13, 'Damaged'); \n" + + "INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (14, 'Prison');\n" + + "\n" + + "\n"; + + + var sqlScript = new MySql.Data.MySqlClient.MySqlScript((MySql.Data.MySqlClient.MySqlConnection)Program.DBCon.Connection); + sqlScript.Query = sqlString; + + sqlScript.Error += sqlScript_Error; + sqlScript.ScriptCompleted += sqlScript_ScriptCompleted; + sqlScript.StatementExecuted += sqlScript_StatementExecuted; + + m_MREvent = new ManualResetEvent(false); + + sqlScript.ExecuteAsync(); + + sqlScript.Error -= sqlScript_Error; + sqlScript.ScriptCompleted -= sqlScript_ScriptCompleted; + sqlScript.StatementExecuted -= sqlScript_StatementExecuted; + + if (!m_MREvent.WaitOne(new TimeSpan(0, 5, 0))) + { + foundError = true; + Program.SplashScreen.InfoAppendLast("finished with errors !"); + } + else if (m_gotScriptErrors) + { + foundError = true; + Program.SplashScreen.InfoAppendLast("finished with errors !"); + } + else + { + Program.SplashScreen.InfoAdd("...updating structure of database to v0.7.3..."); + } + + // mysql settings: update timeout to one week + STA.Settings.INIFile dbIniFile; + + if (Debugger.IsAttached) + dbIniFile = new STA.Settings.INIFile(Path.Combine(Program.IniFile.GetValue("DB_Server", "WorkingDirectory", @"..\..\..\RNDatabase\Database"), "Elite.ini"), false, true, true); + else + dbIniFile = new STA.Settings.INIFile(Program.GetDataPath(@"Database\Elite.ini"), false, true, true); + + dbIniFile.SetValue("mysqld", "wait_timeout", (Int32)604800); + dbIniFile.SetValue("mysqld", "interactive_timeout", (Int32)604800); + + } + catch (Exception ex) + { + throw new Exception("Error while updating to v0.7.2", ex); + } + } + + static void sqlScript_ScriptCompleted(object sender, EventArgs e) { m_MREvent.Set(); diff --git a/RNDatabase/Database/script/create_Elite_DB.sql b/RNDatabase/Database/script/create_Elite_DB.sql index 642c2ab..585ed10 100644 --- a/RNDatabase/Database/script/create_Elite_DB.sql +++ b/RNDatabase/Database/script/create_Elite_DB.sql @@ -1097,7 +1097,7 @@ TRIGGER `elite_db`.`tbCommodityData_AFTER_INSERT` AFTER INSERT ON `elite_db`.`tbcommoditydata` FOR EACH ROW BEGIN - DECLARE isActive BOOLEAN; + DECLARE isActive BOOLEAN; SELECT ((InitValue <> '0') and (InitValue <> 'False')) INTO isActive FROM tbInitValue @@ -1105,11 +1105,11 @@ BEGIN AND InitKey = 'CollectPriceHistory'; IF isActive THEN - INSERT INTO `elite_db`.`tbPriceHistory` - (`station_id`, `commodity_id`, `Sell`, `Buy`, `Demand`, `DemandLevel`, `Supply`, `SupplyLevel`, `Sources_id`, `timestamp`) - VALUES - (NEW.`station_id`, NEW.`commodity_id`, NEW.`Sell`, NEW.`Buy`, NEW.`Demand`, NEW.`DemandLevel`, NEW.`Supply`, NEW.`SupplyLevel`, NEW.`Sources_id`, NEW.`timestamp`); - END IF; + INSERT INTO `elite_db`.`tbPriceHistory` + (`station_id`, `commodity_id`, `Sell`, `Buy`, `Demand`, `DemandLevel`, `Supply`, `SupplyLevel`, `Sources_id`, `timestamp`) + VALUES + (NEW.`station_id`, NEW.`commodity_id`, NEW.`Sell`, NEW.`Buy`, NEW.`Demand`, NEW.`DemandLevel`, NEW.`Supply`, NEW.`SupplyLevel`, NEW.`Sources_id`, NEW.`timestamp`); + END IF; END$$ USE `elite_db`$$ @@ -1119,7 +1119,7 @@ TRIGGER `elite_db`.`tbCommodityData_AFTER_UPDATE` AFTER UPDATE ON `elite_db`.`tbcommoditydata` FOR EACH ROW BEGIN - DECLARE isActive BOOLEAN; + DECLARE isActive BOOLEAN; SELECT ((InitValue <> '0') and (InitValue <> 'False')) INTO isActive FROM tbInitValue @@ -1127,14 +1127,14 @@ BEGIN AND InitKey = 'CollectPriceHistory'; IF isActive THEN - IF (NEW.Sell <> OLD.Sell) OR (NEW.Buy <> OLD.Buy) OR (NEW.Sources_id <> OLD.Sources_id) OR - (TIMESTAMPDIFF(hour, OLD.timestamp, NEW.timestamp) > 24) THEN - INSERT INTO `elite_db`.`tbPriceHistory` - (`station_id`, `commodity_id`, `Sell`, `Buy`, `Demand`, `DemandLevel`, `Supply`, `SupplyLevel`, `Sources_id`, `timestamp`) - VALUES - (NEW.`station_id`, NEW.`commodity_id`, NEW.`Sell`, NEW.`Buy`, NEW.`Demand`, NEW.`DemandLevel`, NEW.`Supply`, NEW.`SupplyLevel`, NEW.`Sources_id`, NEW.`timestamp`); - END IF; - END IF; + IF (NEW.Sell <> OLD.Sell) OR (NEW.Buy <> OLD.Buy) OR (NEW.Sources_id <> OLD.Sources_id) OR + (TIMESTAMPDIFF(hour, OLD.timestamp, NEW.timestamp) > 24) THEN + INSERT INTO `elite_db`.`tbPriceHistory` + (`station_id`, `commodity_id`, `Sell`, `Buy`, `Demand`, `DemandLevel`, `Supply`, `SupplyLevel`, `Sources_id`, `timestamp`) + VALUES + (NEW.`station_id`, NEW.`commodity_id`, NEW.`Sell`, NEW.`Buy`, NEW.`Demand`, NEW.`DemandLevel`, NEW.`Supply`, NEW.`SupplyLevel`, NEW.`Sources_id`, NEW.`timestamp`); + END IF; + END IF; END$$ @@ -1174,6 +1174,11 @@ INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (6, 'Service'); INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (7, 'Terraforming'); INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (8, 'Tourism'); INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (9, 'None'); +INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (10, 'Colony'); +INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (11, 'Repair'); +INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (12, 'Rescue'); +INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (13, 'Damaged'); +INSERT INTO `elite_db`.`tbEconomy` (`id`, `economy`) VALUES (14, 'Prison'); COMMIT; @@ -1305,7 +1310,7 @@ COMMIT; -- ----------------------------------------------------- START TRANSACTION; USE `elite_db`; -INSERT INTO `elite_db`.`tbInitValue` (`InitGroup`, `InitKey`, `InitValue`) VALUES ('Database', 'Version', '0.7.2'); +INSERT INTO `elite_db`.`tbInitValue` (`InitGroup`, `InitKey`, `InitValue`) VALUES ('Database', 'Version', '0.7.3'); INSERT INTO `elite_db`.`tbInitValue` (`InitGroup`, `InitKey`, `InitValue`) VALUES ('Database', 'CollectPriceHistory', 'False'); COMMIT;