summaryrefslogtreecommitdiff
path: root/Aktywator/MySQLTournament.cs
diff options
context:
space:
mode:
authorMichał Zimniewicz <michzimny@users.noreply.github.com>2017-12-06 23:57:31 +0100
committerGitHub <noreply@github.com>2017-12-06 23:57:31 +0100
commit80cd31c1c8e7cef2cfbf6148df3d9ec2d2a23279 (patch)
tree4071e574a3e611cf4d8a19e231ff7ecc659949fa /Aktywator/MySQLTournament.cs
parent83e064ccb67f0b68b1f947026301cd3905d06a3c (diff)
parentf12d2b996b165d66f4c32eef4a3bdfb89309670d (diff)
Merge pull request #29 from michzimny/1.1-beta
Scalenie gałęzi beta do master
Diffstat (limited to 'Aktywator/MySQLTournament.cs')
-rw-r--r--Aktywator/MySQLTournament.cs82
1 files changed, 82 insertions, 0 deletions
diff --git a/Aktywator/MySQLTournament.cs b/Aktywator/MySQLTournament.cs
new file mode 100644
index 0000000..3bc9acc
--- /dev/null
+++ b/Aktywator/MySQLTournament.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using MySql.Data.MySqlClient;
+using data = MySql.Data.MySqlClient.MySqlDataReader;
+
+namespace Aktywator
+{
+ public class MySQLTournament : Tournament
+ {
+ public MySQL mysql;
+
+ 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);
+ }
+
+ public static string getLabel(string name, int type)
+ {
+ return name + " [" + (type == Tournament.TYPE_PARY ? 'P' : 'T') + "]";
+ }
+
+ public override string ToString()
+ {
+ return MySQLTournament.getLabel(this.name, this.type);
+ }
+
+ public static List<TournamentListItem> getTournaments()
+ {
+ List<TournamentListItem> list = new List<TournamentListItem>();
+ MySQL c = new MySQL("");
+ 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())
+ {
+ TournamentListItem item = new TournamentListItem();
+ item.Name = dbs.GetString(0);
+ item.Type = "dnazwa".Equals(dbs.GetString(1)) ? Tournament.TYPE_PARY : Tournament.TYPE_TEAMY;
+ item.Label = MySQLTournament.getLabel(item.Name, item.Type);
+ list.Add(item);
+ }
+ dbs.Close();
+ return list;
+ }
+
+ override internal void setup()
+ {
+ if (this.mysql != null)
+ {
+ this.mysql.close();
+ this.mysql.connect();
+ }
+ }
+
+ override internal string getName()
+ {
+ return this.name;
+ }
+
+ override public string getSectionsNum()
+ {
+ throw new NotImplementedException("Don't call this method on generic class instance");
+ }
+
+ override public string getTablesNum()
+ {
+ throw new NotImplementedException("Don't call this method on generic class instance");
+ }
+
+ override internal string getTypeLabel()
+ {
+ throw new NotImplementedException("Don't call this method on generic class instance");
+ }
+
+ }
+}
+