summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Aktywator/MySQLTournament.cs28
-rw-r--r--Aktywator/ParyTournament.cs4
-rw-r--r--Aktywator/TeamyTournament.cs4
3 files changed, 12 insertions, 24 deletions
diff --git a/Aktywator/MySQLTournament.cs b/Aktywator/MySQLTournament.cs
index c3cb29f..f745a91 100644
--- a/Aktywator/MySQLTournament.cs
+++ b/Aktywator/MySQLTournament.cs
@@ -10,24 +10,15 @@ namespace Aktywator
{
public MySQL mysql;
- public MySQLTournament(string name)
+ public MySQLTournament(string name, int type)
{
this._name = name;
+ this._type = type;
+ if (this._type < Tournament.TYPE_UNKNOWN || this._type > Tournament.TYPE_RRB)
+ {
+ this._type = Tournament.TYPE_UNKNOWN;
+ }
mysql = new MySQL(name);
- recognizeType();
- }
-
- private void recognizeType()
- {
- if ((mysql.selectOne("SHOW TABLES LIKE 'admin'") == "admin")
- && (mysql.selectOne("SHOW FIELDS IN admin LIKE 'dnazwa'") == "dnazwa")
- && (mysql.selectOne("SHOW TABLES LIKE 'zawodnicy'") == "zawodnicy"))
- _type = Tournament.TYPE_PARY;
- else if ((mysql.selectOne("SHOW TABLES LIKE 'admin'") == "admin")
- && (mysql.selectOne("SHOW FIELDS IN admin LIKE 'teamcnt'") == "teamcnt")
- && (mysql.selectOne("SHOW TABLES LIKE 'players'") == "players"))
- _type = Tournament.TYPE_TEAMY;
- else _type = Tournament.TYPE_UNKNOWN;
}
public override string ToString()
@@ -39,13 +30,10 @@ namespace Aktywator
{
List<MySQLTournament> list = new List<MySQLTournament>();
MySQL c = new MySQL("");
- data dbs = c.select("SHOW DATABASES;");
+ data dbs = c.select("SELECT TABLE_SCHEMA, COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_NAME = 'admin' AND COLUMN_NAME IN ('dnazwa', 'teamcnt') ORDER BY TABLE_SCHEMA;");
while (dbs.Read())
{
- MySQLTournament t = new MySQLTournament(dbs.GetString(0));
- if (t.type > Tournament.TYPE_UNKNOWN)
- list.Add(t);
- t.mysql.close();
+ list.Add(new MySQLTournament(dbs.GetString(0), "dnazwa".Equals(dbs.GetString(1)) ? Tournament.TYPE_PARY : Tournament.TYPE_TEAMY));
}
dbs.Close();
return list;
diff --git a/Aktywator/ParyTournament.cs b/Aktywator/ParyTournament.cs
index 4950c3d..2ee7243 100644
--- a/Aktywator/ParyTournament.cs
+++ b/Aktywator/ParyTournament.cs
@@ -7,8 +7,8 @@ namespace Aktywator
{
class ParyTournament: MySQLTournament
{
- public ParyTournament(string name)
- : base(name)
+ public ParyTournament(string name, int type = Tournament.TYPE_PARY)
+ : base(name, type)
{
this._type = Tournament.TYPE_PARY;
}
diff --git a/Aktywator/TeamyTournament.cs b/Aktywator/TeamyTournament.cs
index 7fb4f1c..8da063d 100644
--- a/Aktywator/TeamyTournament.cs
+++ b/Aktywator/TeamyTournament.cs
@@ -7,8 +7,8 @@ namespace Aktywator
{
class TeamyTournament : MySQLTournament
{
- public TeamyTournament(string name)
- : base(name)
+ public TeamyTournament(string name, int type = Tournament.TYPE_TEAMY)
+ : base(name, type)
{
this._type = Tournament.TYPE_TEAMY;
}