mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 20:16:36 -04:00
Organise the files properly.
This commit is contained in:
parent
8bc3fe0675
commit
c6225b9c1f
54
Database/MySQL/MySQLBackend.cs
Normal file
54
Database/MySQL/MySQLBackend.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 MCGalaxy
|
||||||
|
|
||||||
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
|
not use this file except in compliance with the Licenses. You may
|
||||||
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
|
http://www.osedu.org/licenses/ECL-2.0
|
||||||
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
|
or implied. See the Licenses for the specific language governing
|
||||||
|
permissions and limitations under the Licenses.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
|
namespace MCGalaxy.SQL {
|
||||||
|
|
||||||
|
public sealed class MySQLBackend : IDatabaseBackend {
|
||||||
|
|
||||||
|
public static IDatabaseBackend Instance = new MySQLBackend();
|
||||||
|
static ParameterisedQuery queryInstance = new MySQLParameterisedQuery();
|
||||||
|
|
||||||
|
static string connFormat = "Data Source={0};Port={1};User ID={2};Password={3};Pooling={4}";
|
||||||
|
public override string ConnectionString {
|
||||||
|
get { return String.Format(connFormat, Server.MySQLHost, Server.MySQLPort,
|
||||||
|
Server.MySQLUsername, Server.MySQLPassword, Server.DatabasePooling); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override BulkTransaction CreateBulk() {
|
||||||
|
return new MySQLBulkTransaction(ConnectionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ParameterisedQuery CreateParameterised() {
|
||||||
|
return new MySQLParameterisedQuery();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override ParameterisedQuery GetStaticParameterised() {
|
||||||
|
return queryInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool TableExists(string table) {
|
||||||
|
const string syntax = "SELECT * FROM information_schema.tables WHERE table_schema = @1 AND table_name = @0";
|
||||||
|
using (DataTable results = Database.Fill(syntax, table, Server.MySQLDatabaseName))
|
||||||
|
return results.Rows.Count > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
44
Database/MySQL/MySQLBulkTransaction.cs
Normal file
44
Database/MySQL/MySQLBulkTransaction.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
|
not use this file except in compliance with the Licenses. You may
|
||||||
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
|
http://www.osedu.org/licenses/ECL-2.0
|
||||||
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
|
or implied. See the Licenses for the specific language governing
|
||||||
|
permissions and limitations under the Licenses.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
|
namespace MCGalaxy.SQL {
|
||||||
|
|
||||||
|
public sealed class MySQLBulkTransaction : BulkTransaction {
|
||||||
|
|
||||||
|
public MySQLBulkTransaction(string connString) {
|
||||||
|
connection = new MySqlConnection(connString);
|
||||||
|
connection.Open();
|
||||||
|
connection.ChangeDatabase(Server.MySQLDatabaseName);
|
||||||
|
|
||||||
|
transaction = connection.BeginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IDbCommand CreateCommand(string query) {
|
||||||
|
return new MySqlCommand(query, (MySqlConnection)connection, (MySqlTransaction)transaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IDataParameter CreateParam(string paramName, DbType type) {
|
||||||
|
MySqlParameter arg = new MySqlParameter(paramName, null);
|
||||||
|
arg.DbType = type;
|
||||||
|
return arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
|
||||||
Copyright 2011 MCForge
|
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
@ -21,57 +20,6 @@ using System.Data;
|
|||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
namespace MCGalaxy.SQL {
|
namespace MCGalaxy.SQL {
|
||||||
|
|
||||||
public sealed class MySQLBackend : IDatabaseBackend {
|
|
||||||
|
|
||||||
public static IDatabaseBackend Instance = new MySQLBackend();
|
|
||||||
static ParameterisedQuery queryInstance = new SQLiteParameterisedQuery();
|
|
||||||
|
|
||||||
static string connFormat = "Data Source={0};Port={1};User ID={2};Password={3};Pooling={4}";
|
|
||||||
public override string ConnectionString {
|
|
||||||
get { return String.Format(connFormat, Server.MySQLHost, Server.MySQLPort,
|
|
||||||
Server.MySQLUsername, Server.MySQLPassword, Server.DatabasePooling); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override BulkTransaction CreateBulk() {
|
|
||||||
return new MySQLBulkTransaction(ConnectionString);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override ParameterisedQuery CreateParameterised() {
|
|
||||||
return new MySQLParameterisedQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override ParameterisedQuery GetStaticParameterised() {
|
|
||||||
return queryInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool TableExists(string table) {
|
|
||||||
const string syntax = "SELECT * FROM information_schema.tables WHERE table_schema = @1 AND table_name = @0";
|
|
||||||
using (DataTable results = Database.Fill(syntax, table, Server.MySQLDatabaseName))
|
|
||||||
return results.Rows.Count > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class MySQLBulkTransaction : BulkTransaction {
|
|
||||||
|
|
||||||
public MySQLBulkTransaction(string connString) {
|
|
||||||
connection = new MySqlConnection(connString);
|
|
||||||
connection.Open();
|
|
||||||
connection.ChangeDatabase(Server.MySQLDatabaseName);
|
|
||||||
|
|
||||||
transaction = connection.BeginTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IDbCommand CreateCommand(string query) {
|
|
||||||
return new MySqlCommand(query, (MySqlConnection)connection, (MySqlTransaction)transaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IDataParameter CreateParam(string paramName, DbType type) {
|
|
||||||
MySqlParameter arg = new MySqlParameter(paramName, null);
|
|
||||||
arg.DbType = type;
|
|
||||||
return arg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class MySQLParameterisedQuery : ParameterisedQuery {
|
public sealed class MySQLParameterisedQuery : ParameterisedQuery {
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2011 MCForge
|
Copyright 2015 MCGalaxy
|
||||||
|
|
||||||
Dual-licensed under the Educational Community License, Version 2.0 and
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
the GNU General Public License, Version 3 (the "Licenses"); you may
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
@ -43,56 +43,11 @@ namespace MCGalaxy.SQL {
|
|||||||
return queryInstance;
|
return queryInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override bool TableExists(string table) {
|
public override bool TableExists(string table) {
|
||||||
const string syntax = "SELECT name FROM sqlite_master WHERE type='table' AND name=@0";
|
const string syntax = "SELECT name FROM sqlite_master WHERE type='table' AND name=@0";
|
||||||
using (DataTable results = Database.Fill(syntax, table))
|
using (DataTable results = Database.Fill(syntax, table))
|
||||||
return results.Rows.Count > 0;
|
return results.Rows.Count > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class SQLiteBulkTransaction : BulkTransaction {
|
|
||||||
|
|
||||||
public SQLiteBulkTransaction(string connString) {
|
|
||||||
connection = new SQLiteConnection(connString);
|
|
||||||
connection.Open();
|
|
||||||
transaction = connection.BeginTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IDbCommand CreateCommand(string query) {
|
|
||||||
return new SQLiteCommand(query, (SQLiteConnection)connection, (SQLiteTransaction)transaction);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override IDataParameter CreateParam(string paramName, DbType type) {
|
|
||||||
return new SQLiteParameter(paramName, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class SQLiteParameterisedQuery : ParameterisedQuery {
|
|
||||||
|
|
||||||
public override void Execute(string query, string connString, bool createDB = false) {
|
|
||||||
using (var conn = new SQLiteConnection(connString)) {
|
|
||||||
conn.Open();
|
|
||||||
using (SQLiteCommand cmd = new SQLiteCommand(query, conn)) {
|
|
||||||
foreach (var param in parameters)
|
|
||||||
cmd.Parameters.AddWithValue(param.Key, param.Value);
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
}
|
|
||||||
conn.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Fill(string query, string connString, DataTable results) {
|
|
||||||
using (var conn = new SQLiteConnection(connString)) {
|
|
||||||
conn.Open();
|
|
||||||
|
|
||||||
using (SQLiteDataAdapter da = new SQLiteDataAdapter(query, conn)) {
|
|
||||||
foreach (var param in parameters)
|
|
||||||
da.SelectCommand.Parameters.AddWithValue(param.Key, param.Value);
|
|
||||||
da.Fill(results);
|
|
||||||
da.SelectCommand.Dispose();
|
|
||||||
}
|
|
||||||
conn.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
40
Database/SQLite/SQLiteBulkTransaction.cs
Normal file
40
Database/SQLite/SQLiteBulkTransaction.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
|
not use this file except in compliance with the Licenses. You may
|
||||||
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
|
http://www.osedu.org/licenses/ECL-2.0
|
||||||
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
|
or implied. See the Licenses for the specific language governing
|
||||||
|
permissions and limitations under the Licenses.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SQLite;
|
||||||
|
|
||||||
|
namespace MCGalaxy.SQL {
|
||||||
|
|
||||||
|
public sealed class SQLiteBulkTransaction : BulkTransaction {
|
||||||
|
|
||||||
|
public SQLiteBulkTransaction(string connString) {
|
||||||
|
connection = new SQLiteConnection(connString);
|
||||||
|
connection.Open();
|
||||||
|
transaction = connection.BeginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IDbCommand CreateCommand(string query) {
|
||||||
|
return new SQLiteCommand(query, (SQLiteConnection)connection, (SQLiteTransaction)transaction);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IDataParameter CreateParam(string paramName, DbType type) {
|
||||||
|
return new SQLiteParameter(paramName, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
52
Database/SQLite/SQLiteParameterisedQuery.cs
Normal file
52
Database/SQLite/SQLiteParameterisedQuery.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2011 MCForge
|
||||||
|
|
||||||
|
Dual-licensed under the Educational Community License, Version 2.0 and
|
||||||
|
the GNU General Public License, Version 3 (the "Licenses"); you may
|
||||||
|
not use this file except in compliance with the Licenses. You may
|
||||||
|
obtain a copy of the Licenses at
|
||||||
|
|
||||||
|
http://www.osedu.org/licenses/ECL-2.0
|
||||||
|
http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the Licenses are distributed on an "AS IS"
|
||||||
|
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
||||||
|
or implied. See the Licenses for the specific language governing
|
||||||
|
permissions and limitations under the Licenses.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SQLite;
|
||||||
|
|
||||||
|
namespace MCGalaxy.SQL {
|
||||||
|
|
||||||
|
public sealed class SQLiteParameterisedQuery : ParameterisedQuery {
|
||||||
|
|
||||||
|
public override void Execute(string query, string connString, bool createDB = false) {
|
||||||
|
using (var conn = new SQLiteConnection(connString)) {
|
||||||
|
conn.Open();
|
||||||
|
using (SQLiteCommand cmd = new SQLiteCommand(query, conn)) {
|
||||||
|
foreach (var param in parameters)
|
||||||
|
cmd.Parameters.AddWithValue(param.Key, param.Value);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Fill(string query, string connString, DataTable results) {
|
||||||
|
using (var conn = new SQLiteConnection(connString)) {
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
using (SQLiteDataAdapter da = new SQLiteDataAdapter(query, conn)) {
|
||||||
|
foreach (var param in parameters)
|
||||||
|
da.SelectCommand.Parameters.AddWithValue(param.Key, param.Value);
|
||||||
|
da.Fill(results);
|
||||||
|
da.SelectCommand.Dispose();
|
||||||
|
}
|
||||||
|
conn.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -405,11 +405,15 @@
|
|||||||
<Compile Include="Config\Properties.cs" />
|
<Compile Include="Config\Properties.cs" />
|
||||||
<Compile Include="Config\PropertiesFile.cs" />
|
<Compile Include="Config\PropertiesFile.cs" />
|
||||||
<Compile Include="Config\StringAttributes.cs" />
|
<Compile Include="Config\StringAttributes.cs" />
|
||||||
<Compile Include="Database\Backends\IDatabaseBackend.cs" />
|
|
||||||
<Compile Include="Database\Backends\SQLiteBackend.cs" />
|
|
||||||
<Compile Include="Database\Backends\MySQLBackend.cs" />
|
|
||||||
<Compile Include="Database\BlockDB.cs" />
|
<Compile Include="Database\BlockDB.cs" />
|
||||||
|
<Compile Include="Database\IDatabaseBackend.cs" />
|
||||||
|
<Compile Include="Database\MySQL\MySQLBackend.cs" />
|
||||||
|
<Compile Include="Database\MySQL\MySQLBulkTransaction.cs" />
|
||||||
|
<Compile Include="Database\MySQL\MySQLParameterisedQuery.cs" />
|
||||||
<Compile Include="Database\ParameterisedQuery.cs" />
|
<Compile Include="Database\ParameterisedQuery.cs" />
|
||||||
|
<Compile Include="Database\SQLite\SQLiteBackend.cs" />
|
||||||
|
<Compile Include="Database\SQLite\SQLiteBulkTransaction.cs" />
|
||||||
|
<Compile Include="Database\SQLite\SQLiteParameterisedQuery.cs" />
|
||||||
<Compile Include="Drawing\Brushes\Brush.cs" />
|
<Compile Include="Drawing\Brushes\Brush.cs" />
|
||||||
<Compile Include="Drawing\Brushes\CloudyBrush.cs" />
|
<Compile Include="Drawing\Brushes\CloudyBrush.cs" />
|
||||||
<Compile Include="Drawing\Brushes\PasteBrush.cs" />
|
<Compile Include="Drawing\Brushes\PasteBrush.cs" />
|
||||||
@ -694,7 +698,8 @@
|
|||||||
<Folder Include="Commands\Scripting" />
|
<Folder Include="Commands\Scripting" />
|
||||||
<Folder Include="Commands\World" />
|
<Folder Include="Commands\World" />
|
||||||
<Folder Include="Commands\other" />
|
<Folder Include="Commands\other" />
|
||||||
<Folder Include="Database\Backends" />
|
<Folder Include="Database\MySQL" />
|
||||||
|
<Folder Include="Database\SQLite" />
|
||||||
<Folder Include="Drawing\DrawOps" />
|
<Folder Include="Drawing\DrawOps" />
|
||||||
<Folder Include="Drawing\Brushes" />
|
<Folder Include="Drawing\Brushes" />
|
||||||
<Folder Include="Drawing\Image" />
|
<Folder Include="Drawing\Image" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user