diff options
author | emkael <emkael@tlen.pl> | 2017-07-30 03:36:29 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-07-30 03:36:29 +0200 |
commit | 6c056322e96ab0ebbf52c3f35ec8b0a51f1b5f8d (patch) | |
tree | b68cc969c865c818a2965a444e86d1df8885e101 /Aktywator | |
parent | 14f684cee81e45ebaea0dd0abb60c5039a7ed467 (diff) |
Universal pairs data reading from BWS (independent on tournament type and integer type used in BWS)
Diffstat (limited to 'Aktywator')
-rw-r--r-- | Aktywator/Bws.cs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Aktywator/Bws.cs b/Aktywator/Bws.cs index 5302454..7f8a899 100644 --- a/Aktywator/Bws.cs +++ b/Aktywator/Bws.cs @@ -342,15 +342,27 @@ namespace Aktywator else return 0; } + private int getBWSNumber(OleDbDataReader reader, int index) + { + switch (Type.GetTypeCode(reader.GetFieldType(index))) + { + case TypeCode.Int16: + return reader.GetInt16(index); + case TypeCode.Int32: + return reader.GetInt32(index); + } + throw new InvalidCastException("Unable to read numeric value from BWS field"); + } + public void syncNames(Tournament tournament, bool interactive, string startRounds) { int count = 0, countNew = 0, SKOK_STOLOW = 100; OleDbDataReader d; startRounds = startRounds.Trim(); - if (tournament.type == Tournament.TYPE_PARY) + if (tournament.type != Tournament.TYPE_TEAMY) { - if (startRounds.Length > 0) + if (tournament.type == Tournament.TYPE_PARY && startRounds.Length > 0) { d = sql.select("SELECT `Section`, `Table`, NSPair, EWPair FROM RoundData WHERE NSPair>0 AND `Round` in (" + startRounds + ")"); } @@ -371,10 +383,10 @@ namespace Aktywator while (d.Read()) { - string section = d.GetInt32(0).ToString(); - string table = d.GetInt32(1).ToString(); - int ns = d.GetInt32(2); - int ew = d.GetInt32(3); + string section = this.getBWSNumber(d, 0).ToString(); + string table = this.getBWSNumber(d, 1).ToString(); + int ns = this.getBWSNumber(d, 2); + int ew = this.getBWSNumber(d, 3); try { |