Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions ED-IBE/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -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")]
73 changes: 72 additions & 1 deletion ED-IBE/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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...<OK>");
}

// 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();
Expand Down
37 changes: 21 additions & 16 deletions RNDatabase/Database/script/create_Elite_DB.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1097,19 +1097,19 @@ 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
WHERE InitGroup = 'Database'
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`$$
Expand All @@ -1119,22 +1119,22 @@ 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
WHERE InitGroup = 'Database'
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$$


Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down